public class SearchHitImpl extends AbstractSearchEntry implements SearchHit
SearchHit interface.| Modifier and Type | Field and Description |
|---|---|
private SearchEntry |
entry
the actual entry this hit delegates to
|
private String |
entryId |
private SearchHighlighter |
highlighter
the highlighter
|
private double |
score |
HIGHLIGHT_CUT_TEXT, HIGHLIGHT_END_TAG, HIGHLIGHT_START_TAG, NO_HITSFIELD_CREATOR, FIELD_CUSTOM_ID, FIELD_ID, FIELD_KEYWORDS, FIELD_LANGUAGE, FIELD_SIZE, FIELD_SOURCE, FIELD_TEXT, FIELD_TITLE, FIELD_TYPE, FIELD_URI| Constructor and Description |
|---|
SearchHitImpl(SearchEntry searchEntry,
String entryId,
double hitScore,
SearchHighlighter searchHighlighter)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getEntryId()
This method gets the ID of this hit in the search index.
|
Object |
getField(String name)
This method is a generic accessor for fields of this
entry. |
<T> T |
getField(String name,
Class<T> type)
This method is a generic accessor for fields of this
entry with a specific
type. |
String |
getFieldAsString(String name)
This method is a shortcut for
. |
Iterator<String> |
getFieldNames()
This method gets the names of all
fields that are defined (NOT
null). |
String |
getHighlightedText()
This method gets an excerpt of the plain text of the content that contains terms of the search query as a
highlighted html fragment.
|
double |
getScore()
This method gets the score of this hit.
|
int |
getScore(int maximum)
This method gets the score of this hit as an integer value in the range from
0 to
maximum. |
equals, getCreator, getCustomId, getId, getSize, getSource, getText, getTitle, getType, getUri, hashCode, toStringgetLoggerclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetCreator, getCustomId, getId, getSize, getSource, getText, getTitle, getType, getUriprivate final SearchEntry entry
private final String entryId
AbstractSearchEntry.getId()private final double score
getScore()private final SearchHighlighter highlighter
public SearchHitImpl(SearchEntry searchEntry, String entryId, double hitScore, SearchHighlighter searchHighlighter)
searchEntry - is the actual entry this hit delegates to.entryId - is the entry-ID.hitScore - is the score of the hit.searchHighlighter - is the highlighter used for highlighting.public double getScore()
0 to
1, where 1 represents a perfect hit and 0 represents a hit that
has nothing in common with the search query. A hit will typically NOT have a score of
0 but the score may be close to 0.public int getScore(int maximum)
0 to
maximum. The higher the score the better the hit. This method is useful to view the score as
a percentage value (with a maximum of 100) or a number of stars (e.g. with a
maximum of 5).getScore in interface SearchHitmaximum - is the maximum scoreSearchHit.getScore()public String getHighlightedText()
SearchHit.HIGHLIGHT_START_TAG and SearchHit.HIGHLIGHT_END_TAG
and parts of the text that have been cut out should be replaced with SearchHit.HIGHLIGHT_CUT_TEXT. An
implementing search-engine component may allow to override these defaults for custom needs.getHighlightedText in interface SearchHitSearchEntry.getText()public String getEntryId()
retrieve the entry again. It is explicitly unspecified and may vary
in implementations if this is the same as SearchEntry.getId().getEntryId in interface SearchHitpublic String getFieldAsString(String name)
getField(name, String.class).getFieldAsString in interface SearchEntrygetFieldAsString in class AbstractSearchEntryname - is the name of the
requested field.null if no field exists for the given
name.public Object getField(String name)
entry. For the predefine fields
(see FIELD_* constants like SearchEntry.FIELD_TEXT) there are specific getter methods like
SearchEntry.getText().getField in interface SearchEntryname - is the name of the
requested field.type.SearchEntry.getField(String, Class)public <T> T getField(String name, Class<T> type)
entry with a specific
type. String will always work. Other types have to be compatible to the
field type (or a
RuntimeException will be thrown).getField in interface SearchEntryT - is the generic type expected for the requested field-value (see parameter type).name - is the name of the
requested field.type - is the type of the requested field.null if no field exists for the given
name.public Iterator<String> getFieldNames()
fields that are defined (NOT
null).getFieldNames in interface SearchEntryCopyright © 2001–2016 mmm-Team. All rights reserved.