Class AbstractHighlighterBuilder<HB extends AbstractHighlighterBuilder<?>>
java.lang.Object
org.elasticsearch.search.fetch.subphase.highlight.AbstractHighlighterBuilder<HB>
- All Implemented Interfaces:
Writeable,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentObject,Rewriteable<HB>
- Direct Known Subclasses:
HighlightBuilder,HighlightBuilder.Field
public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterBuilder<?>> extends java.lang.Object implements Writeable, Rewriteable<HB>, org.elasticsearch.common.xcontent.ToXContentObject
This abstract class holds parameters shared by
HighlightBuilder and HighlightBuilder.Field
and provides the common setters, equality, hashCode calculation and common serialization-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description static org.elasticsearch.common.ParseFieldBOUNDARY_CHARS_FIELDstatic org.elasticsearch.common.ParseFieldBOUNDARY_MAX_SCAN_FIELDstatic org.elasticsearch.common.ParseFieldBOUNDARY_SCANNER_FIELDstatic org.elasticsearch.common.ParseFieldBOUNDARY_SCANNER_LOCALE_FIELDprotected char[]boundaryCharsprotected java.lang.IntegerboundaryMaxScanprotected java.util.LocaleboundaryScannerLocaleprotected HighlightBuilder.BoundaryScannerTypeboundaryScannerTypestatic org.elasticsearch.common.ParseFieldENCODER_FIELDstatic org.elasticsearch.common.ParseFieldFIELDS_FIELDstatic org.elasticsearch.common.ParseFieldFORCE_SOURCE_FIELDprotected java.lang.BooleanforceSourcestatic org.elasticsearch.common.ParseFieldFRAGMENT_OFFSET_FIELDstatic org.elasticsearch.common.ParseFieldFRAGMENT_SIZE_FIELDprotected java.lang.Stringfragmenterstatic org.elasticsearch.common.ParseFieldFRAGMENTER_FIELDprotected java.lang.IntegerfragmentSizestatic org.elasticsearch.common.ParseFieldHIGHLIGHT_FILTER_FIELDstatic org.elasticsearch.common.ParseFieldHIGHLIGHT_QUERY_FIELDprotected java.lang.StringhighlighterTypeprotected java.lang.BooleanhighlightFilterprotected QueryBuilderhighlightQuerystatic org.elasticsearch.common.ParseFieldMATCHED_FIELDS_FIELDstatic org.elasticsearch.common.ParseFieldNO_MATCH_SIZE_FIELDprotected java.lang.IntegernoMatchSizestatic org.elasticsearch.common.ParseFieldNUMBER_OF_FRAGMENTS_FIELDprotected java.lang.IntegernumOfFragmentsprotected java.util.Map<java.lang.String,java.lang.Object>optionsstatic org.elasticsearch.common.ParseFieldOPTIONS_FIELDprotected HighlightBuilder.Orderorderstatic org.elasticsearch.common.ParseFieldORDER_FIELDstatic org.elasticsearch.common.ParseFieldPHRASE_LIMIT_FIELDprotected java.lang.IntegerphraseLimitstatic org.elasticsearch.common.ParseFieldPOST_TAGS_FIELDprotected java.lang.String[]postTagsstatic org.elasticsearch.common.ParseFieldPRE_TAGS_FIELDprotected java.lang.String[]preTagsstatic org.elasticsearch.common.ParseFieldREQUIRE_FIELD_MATCH_FIELDprotected java.lang.BooleanrequireFieldMatchstatic org.elasticsearch.common.ParseFieldTYPE_FIELD -
Constructor Summary
Constructors Modifier Constructor Description AbstractHighlighterBuilder()protectedAbstractHighlighterBuilder(StreamInput in)Read from a stream.protectedAbstractHighlighterBuilder(AbstractHighlighterBuilder<?> template, QueryBuilder queryBuilder) -
Method Summary
Modifier and Type Method Description char[]boundaryChars()HBboundaryChars(char[] boundaryChars)When using the highlighterTypefvhthis setting defines what constitutes a boundary for highlighting.java.lang.IntegerboundaryMaxScan()HBboundaryMaxScan(java.lang.Integer boundaryMaxScan)When using the highlighterTypefvhthis setting controls how far to look for boundary characters, and defaults to 20.java.util.LocaleboundaryScannerLocale()HBboundaryScannerLocale(java.lang.String boundaryScannerLocale)When using the highlighterTypefvhand boundaryScannerTypebreak_iterator, this setting controls the locale to use by the BreakIterator, defaults to "root".HighlightBuilder.BoundaryScannerTypeboundaryScannerType()HBboundaryScannerType(java.lang.String boundaryScannerType)When using the highlighterTypefvhthis setting controls which scanner to use for fragment boundaries, and defaults to "simple".HBboundaryScannerType(HighlightBuilder.BoundaryScannerType boundaryScannerType)When using the highlighterTypefvhthis setting controls which scanner to use for fragment boundaries, and defaults to "simple".protected abstract booleandoEquals(HB other)fields only present in subclass should be checked for equality in the implementationprotected abstract intdoHashCode()fields only present in subclass should contribute to hashCode in the implementationprotected abstract voiddoWriteTo(StreamOutput out)booleanequals(java.lang.Object obj)java.lang.BooleanforceSource()HBforceSource(java.lang.Boolean forceSource)Forces the highlighting to highlight fields based on the source even if fields are stored separately.java.lang.Stringfragmenter()HBfragmenter(java.lang.String fragmenter)Sets what fragmenter to use to break up text that is eligible for highlighting.java.lang.IntegerfragmentSize()HBfragmentSize(java.lang.Integer fragmentSize)Set the fragment size in characters, defaults toHighlightBuilder.DEFAULT_FRAGMENT_CHAR_SIZEinthashCode()java.lang.StringhighlighterType()HBhighlighterType(java.lang.String highlighterType)Set type of highlighter to use.java.lang.BooleanhighlightFilter()HBhighlightFilter(java.lang.Boolean highlightFilter)Set this to true when using the highlighterTypefvhand you want to provide highlighting on filter clauses in your query.QueryBuilderhighlightQuery()HBhighlightQuery(QueryBuilder highlightQuery)Sets a query to be used for highlighting instead of the search query.protected abstract voidinnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder)java.lang.IntegernoMatchSize()HBnoMatchSize(java.lang.Integer noMatchSize)Sets the size of the fragment to return from the beginning of the field if there are no matches to highlight and the field doesn't also define noMatchSize.java.lang.IntegernumOfFragments()HBnumOfFragments(java.lang.Integer numOfFragments)Set the number of fragments, defaults toHighlightBuilder.DEFAULT_NUMBER_OF_FRAGMENTSjava.util.Map<java.lang.String,java.lang.Object>options()HBoptions(java.util.Map<java.lang.String,java.lang.Object> options)Allows to set custom options for custom highlighters.HighlightBuilder.Orderorder()HBorder(java.lang.String order)The order of fragments per field.HBorder(HighlightBuilder.Order scoreOrdered)By default, fragments of a field are ordered by the order in the highlighted text.java.lang.IntegerphraseLimit()HBphraseLimit(java.lang.Integer phraseLimit)Sets the maximum number of phrases the fvh will consider if the field doesn't also define phraseLimit.java.lang.String[]postTags()HBpostTags(java.lang.String... postTags)Set the post tags that will be used for highlighting.java.lang.String[]preTags()HBpreTags(java.lang.String... preTags)Set the pre tags that will be used for highlighting.java.lang.BooleanrequireFieldMatch()HBrequireFieldMatch(java.lang.Boolean requireFieldMatch)Set to true to cause a field to be highlighted only if a query matches that field.java.lang.StringtoString()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)voidwriteTo(StreamOutput out)write common parameters toStreamOutput
-
Field Details
-
PRE_TAGS_FIELD
public static final org.elasticsearch.common.ParseField PRE_TAGS_FIELD -
POST_TAGS_FIELD
public static final org.elasticsearch.common.ParseField POST_TAGS_FIELD -
FIELDS_FIELD
public static final org.elasticsearch.common.ParseField FIELDS_FIELD -
ORDER_FIELD
public static final org.elasticsearch.common.ParseField ORDER_FIELD -
HIGHLIGHT_FILTER_FIELD
public static final org.elasticsearch.common.ParseField HIGHLIGHT_FILTER_FIELD -
FRAGMENT_SIZE_FIELD
public static final org.elasticsearch.common.ParseField FRAGMENT_SIZE_FIELD -
FRAGMENT_OFFSET_FIELD
public static final org.elasticsearch.common.ParseField FRAGMENT_OFFSET_FIELD -
NUMBER_OF_FRAGMENTS_FIELD
public static final org.elasticsearch.common.ParseField NUMBER_OF_FRAGMENTS_FIELD -
ENCODER_FIELD
public static final org.elasticsearch.common.ParseField ENCODER_FIELD -
REQUIRE_FIELD_MATCH_FIELD
public static final org.elasticsearch.common.ParseField REQUIRE_FIELD_MATCH_FIELD -
BOUNDARY_SCANNER_FIELD
public static final org.elasticsearch.common.ParseField BOUNDARY_SCANNER_FIELD -
BOUNDARY_MAX_SCAN_FIELD
public static final org.elasticsearch.common.ParseField BOUNDARY_MAX_SCAN_FIELD -
BOUNDARY_CHARS_FIELD
public static final org.elasticsearch.common.ParseField BOUNDARY_CHARS_FIELD -
BOUNDARY_SCANNER_LOCALE_FIELD
public static final org.elasticsearch.common.ParseField BOUNDARY_SCANNER_LOCALE_FIELD -
TYPE_FIELD
public static final org.elasticsearch.common.ParseField TYPE_FIELD -
FRAGMENTER_FIELD
public static final org.elasticsearch.common.ParseField FRAGMENTER_FIELD -
NO_MATCH_SIZE_FIELD
public static final org.elasticsearch.common.ParseField NO_MATCH_SIZE_FIELD -
FORCE_SOURCE_FIELD
public static final org.elasticsearch.common.ParseField FORCE_SOURCE_FIELD -
PHRASE_LIMIT_FIELD
public static final org.elasticsearch.common.ParseField PHRASE_LIMIT_FIELD -
OPTIONS_FIELD
public static final org.elasticsearch.common.ParseField OPTIONS_FIELD -
HIGHLIGHT_QUERY_FIELD
public static final org.elasticsearch.common.ParseField HIGHLIGHT_QUERY_FIELD -
MATCHED_FIELDS_FIELD
public static final org.elasticsearch.common.ParseField MATCHED_FIELDS_FIELD -
preTags
protected java.lang.String[] preTags -
postTags
protected java.lang.String[] postTags -
fragmentSize
protected java.lang.Integer fragmentSize -
numOfFragments
protected java.lang.Integer numOfFragments -
highlighterType
protected java.lang.String highlighterType -
fragmenter
protected java.lang.String fragmenter -
highlightQuery
-
order
-
highlightFilter
protected java.lang.Boolean highlightFilter -
forceSource
protected java.lang.Boolean forceSource -
boundaryScannerType
-
boundaryMaxScan
protected java.lang.Integer boundaryMaxScan -
boundaryChars
protected char[] boundaryChars -
boundaryScannerLocale
protected java.util.Locale boundaryScannerLocale -
noMatchSize
protected java.lang.Integer noMatchSize -
phraseLimit
protected java.lang.Integer phraseLimit -
options
protected java.util.Map<java.lang.String,java.lang.Object> options -
requireFieldMatch
protected java.lang.Boolean requireFieldMatch
-
-
Constructor Details
-
AbstractHighlighterBuilder
public AbstractHighlighterBuilder() -
AbstractHighlighterBuilder
protected AbstractHighlighterBuilder(AbstractHighlighterBuilder<?> template, QueryBuilder queryBuilder) -
AbstractHighlighterBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
writeTo
write common parameters toStreamOutput -
doWriteTo
- Throws:
java.io.IOException
-
preTags
Set the pre tags that will be used for highlighting. -
preTags
public java.lang.String[] preTags()- Returns:
- the value set by
preTags(String...)
-
postTags
Set the post tags that will be used for highlighting. -
postTags
public java.lang.String[] postTags()- Returns:
- the value set by
postTags(String...)
-
fragmentSize
Set the fragment size in characters, defaults toHighlightBuilder.DEFAULT_FRAGMENT_CHAR_SIZE -
fragmentSize
public java.lang.Integer fragmentSize()- Returns:
- the value set by
fragmentSize(Integer)
-
numOfFragments
Set the number of fragments, defaults toHighlightBuilder.DEFAULT_NUMBER_OF_FRAGMENTS -
numOfFragments
public java.lang.Integer numOfFragments()- Returns:
- the value set by
numOfFragments(Integer)
-
highlighterType
Set type of highlighter to use. Out of the box supported types areunified,plainandfvh. Defaults tounified. Details of the different highlighter types are covered in the reference guide. -
highlighterType
public java.lang.String highlighterType()- Returns:
- the value set by
highlighterType(String)
-
fragmenter
Sets what fragmenter to use to break up text that is eligible for highlighting. This option is only applicable when using the plain highlighterTypehighlighter. Permitted values are "simple" or "span" relating toSimpleFragmenterandSimpleSpanFragmenterimplementations respectively with the default being "span" -
fragmenter
public java.lang.String fragmenter()- Returns:
- the value set by
fragmenter(String)
-
highlightQuery
Sets a query to be used for highlighting instead of the search query. -
highlightQuery
- Returns:
- the value set by
highlightQuery(QueryBuilder)
-
order
The order of fragments per field. By default, ordered by the order in the highlighted text. Can bescore, which then it will be ordered by score of the fragments, ornone. -
order
By default, fragments of a field are ordered by the order in the highlighted text. If set toHighlightBuilder.Order.SCORE, this changes order to score of the fragments. -
order
- Returns:
- the value set by
order(Order)
-
highlightFilter
Set this to true when using the highlighterTypefvhand you want to provide highlighting on filter clauses in your query. Default isfalse. -
highlightFilter
public java.lang.Boolean highlightFilter()- Returns:
- the value set by
highlightFilter(Boolean)
-
boundaryScannerType
When using the highlighterTypefvhthis setting controls which scanner to use for fragment boundaries, and defaults to "simple". -
boundaryScannerType
When using the highlighterTypefvhthis setting controls which scanner to use for fragment boundaries, and defaults to "simple". -
boundaryScannerType
- Returns:
- the value set by
boundaryScannerType(String)
-
boundaryMaxScan
When using the highlighterTypefvhthis setting controls how far to look for boundary characters, and defaults to 20. -
boundaryMaxScan
public java.lang.Integer boundaryMaxScan()- Returns:
- the value set by
boundaryMaxScan(Integer)
-
boundaryChars
When using the highlighterTypefvhthis setting defines what constitutes a boundary for highlighting. It’s a single string with each boundary character defined in it. It defaults to .,!? \t\n -
boundaryChars
public char[] boundaryChars()- Returns:
- the value set by
boundaryChars(char[])
-
boundaryScannerLocale
When using the highlighterTypefvhand boundaryScannerTypebreak_iterator, this setting controls the locale to use by the BreakIterator, defaults to "root". -
boundaryScannerLocale
public java.util.Locale boundaryScannerLocale()- Returns:
- the value set by
boundaryScannerLocale(String)
-
options
Allows to set custom options for custom highlighters. -
options
public java.util.Map<java.lang.String,java.lang.Object> options()- Returns:
- the value set by
options(Map)
-
requireFieldMatch
Set to true to cause a field to be highlighted only if a query matches that field. Default is false meaning that terms are highlighted on all requested fields regardless if the query matches specifically on them. -
requireFieldMatch
public java.lang.Boolean requireFieldMatch()- Returns:
- the value set by
requireFieldMatch(Boolean)
-
noMatchSize
Sets the size of the fragment to return from the beginning of the field if there are no matches to highlight and the field doesn't also define noMatchSize.- Parameters:
noMatchSize- integer to set or null to leave out of request. default is null.- Returns:
- this for chaining
-
noMatchSize
public java.lang.Integer noMatchSize()- Returns:
- the value set by
noMatchSize(Integer)
-
phraseLimit
Sets the maximum number of phrases the fvh will consider if the field doesn't also define phraseLimit.- Parameters:
phraseLimit- maximum number of phrases the fvh will consider- Returns:
- this for chaining
-
phraseLimit
public java.lang.Integer phraseLimit()- Returns:
- the value set by
phraseLimit(Integer)
-
forceSource
Forces the highlighting to highlight fields based on the source even if fields are stored separately. -
forceSource
public java.lang.Boolean forceSource()- Returns:
- the value set by
forceSource(Boolean)
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
innerXContent
protected abstract void innerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder) throws java.io.IOException- Throws:
java.io.IOException
-
hashCode
public final int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
doHashCode
protected abstract int doHashCode()fields only present in subclass should contribute to hashCode in the implementation -
equals
public final boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
doEquals
fields only present in subclass should be checked for equality in the implementation -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-