org.gcube.indexmanagement.lucenewrapper
Class HighlighterWrapper

java.lang.Object
  extended by org.gcube.indexmanagement.lucenewrapper.HighlighterWrapper

public class HighlighterWrapper
extends Object

A wrapper for the highlight functionality of lucene . See Highlighter javadoc Note: we use the version 2.4.1, not the 2.9.1 that is referring to the above link

Since:
12-23-2011
Version:
1.1
Author:
Alexandros Antoniadis

Constructor Summary
HighlighterWrapper(org.apache.lucene.index.IndexReader indexReader)
           
 
Method Summary
 List<String> getDocSnippets(org.apache.lucene.document.Document doc, HashMap<String,ArrayList<String>> queryMap)
          Highlights chosen terms of fields in a document, extracting the most relevant sections
 org.apache.lucene.index.IndexReader getIndexReader()
           
 Integer getMaximumSnippetsCount()
           
 Integer getSnippetSize()
           
static String getSnippetString(List<String> snippets)
          Transforms a list of snippets into a formatted string
 void setIndexReader(org.apache.lucene.index.IndexReader indexReader)
           
 void setMaximumSnippetsCount(Integer maximumSnippetsCount)
           
 void setSnippetSize(Integer snippetSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighlighterWrapper

public HighlighterWrapper(org.apache.lucene.index.IndexReader indexReader)
Method Detail

getSnippetSize

public Integer getSnippetSize()

setSnippetSize

public void setSnippetSize(Integer snippetSize)

getMaximumSnippetsCount

public Integer getMaximumSnippetsCount()

setMaximumSnippetsCount

public void setMaximumSnippetsCount(Integer maximumSnippetsCount)

getIndexReader

public org.apache.lucene.index.IndexReader getIndexReader()

setIndexReader

public void setIndexReader(org.apache.lucene.index.IndexReader indexReader)

getDocSnippets

public List<String> getDocSnippets(org.apache.lucene.document.Document doc,
                                   HashMap<String,ArrayList<String>> queryMap)
                            throws Exception
Highlights chosen terms of fields in a document, extracting the most relevant sections

Parameters:
doc - the document that will be highlighted
queryMap - a mapping of all the fields and the attributes
Returns:
a list of highlighted text fragment or null if no terms found
Throws:
Exception

getSnippetString

public static String getSnippetString(List<String> snippets)
Transforms a list of snippets into a formatted string

Parameters:
snippets - The list of the snippets
Returns:
a string that contains all the snippets concatenated


Copyright © 2013. All Rights Reserved.