public abstract class AbstractExcerpt extends Object implements HighlightingExcerptProvider
AbstractExcerpt
implements base functionality for an excerpt
provider.Modifier and Type | Field and Description |
---|---|
protected SearchIndex |
index
The search index.
|
protected org.apache.lucene.search.Query |
query
The current query.
|
REP_EXCERPT
Constructor and Description |
---|
AbstractExcerpt() |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
createExcerpt(org.apache.lucene.index.TermPositionVector tpv,
String text,
int maxFragments,
int maxFragmentSize)
Creates an excerpt for the given
text using token offset
information provided by tpv . |
String |
getExcerpt(NodeId id,
int maxFragments,
int maxFragmentSize)
Returns the XML excerpt for the node with
id . |
protected Set<org.apache.lucene.index.Term[]> |
getQueryTerms() |
String |
highlight(String text)
Highlights the matching terms in the passed
text . |
void |
init(org.apache.lucene.search.Query query,
SearchIndex index)
Initializes this excerpt provider.
|
protected SearchIndex index
protected org.apache.lucene.search.Query query
public void init(org.apache.lucene.search.Query query, SearchIndex index) throws IOException
init
in interface ExcerptProvider
query
- excerpts will be based on this query.index
- provides access to the search index.IOException
- if an error occurs while initializing this excerpt
provider.public String getExcerpt(NodeId id, int maxFragments, int maxFragmentSize) throws IOException
id
.getExcerpt
in interface ExcerptProvider
id
- a node id.maxFragments
- the maximum number of fragments to create.maxFragmentSize
- the maximum number of characters in a fragment.null
if there is no node with
id
.IOException
- if an error occurs while creating the excerpt.public String highlight(String text) throws IOException
text
.highlight
in interface HighlightingExcerptProvider
text
- the input text.IOException
- if an error occurs while highlighting the text.protected abstract String createExcerpt(org.apache.lucene.index.TermPositionVector tpv, String text, int maxFragments, int maxFragmentSize) throws IOException
text
using token offset
information provided by tpv
.tpv
- the term position vector for the fulltext field.text
- the original text.maxFragments
- the maximum number of fragments to create.maxFragmentSize
- the maximum number of characters in a fragment.IOException
- if an error occurs while creating the excerpt.protected final Set<org.apache.lucene.index.Term[]> getQueryTerms()
Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.