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 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.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
protected char[]
protected Integer
protected Locale
protected HighlightBuilder.BoundaryScannerType
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
protected Boolean
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
protected String
static org.elasticsearch.common.xcontent.ParseField
protected Integer
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
protected String
protected Boolean
protected QueryBuilder
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
protected Integer
static org.elasticsearch.common.xcontent.ParseField
protected Integer
static org.elasticsearch.common.xcontent.ParseField
protected Integer
static org.elasticsearch.common.xcontent.ParseField
protected HighlightBuilder.Order
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
protected Integer
static org.elasticsearch.common.xcontent.ParseField
protected String[]
static org.elasticsearch.common.xcontent.ParseField
protected String[]
static org.elasticsearch.common.xcontent.ParseField
protected Boolean
static org.elasticsearch.common.xcontent.ParseField
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionprotected
Read from a stream.protected
AbstractHighlighterBuilder(AbstractHighlighterBuilder<?> template, QueryBuilder queryBuilder)
-
Method Summary
Modifier and TypeMethodDescriptionchar[]
boundaryChars(char[] boundaryChars)
When using the highlighterTypefvh
this setting defines what constitutes a boundary for highlighting.boundaryMaxScan(Integer boundaryMaxScan)
When using the highlighterTypefvh
this setting controls how far to look for boundary characters, and defaults to 20.boundaryScannerLocale(String boundaryScannerLocale)
When using the highlighterTypefvh
and boundaryScannerTypebreak_iterator
, this setting controls the locale to use by the BreakIterator, defaults to "root".boundaryScannerType(String boundaryScannerType)
When using the highlighterTypefvh
this setting controls which scanner to use for fragment boundaries, and defaults to "simple".boundaryScannerType(HighlightBuilder.BoundaryScannerType boundaryScannerType)
When using the highlighterTypefvh
this setting controls which scanner to use for fragment boundaries, and defaults to "simple".protected abstract boolean
fields only present in subclass should be checked for equality in the implementationprotected abstract int
fields only present in subclass should contribute to hashCode in the implementationprotected abstract void
doWriteTo(StreamOutput out)
boolean
forceSource(Boolean forceSource)
Forces the highlighting to highlight fields based on the source even if fields are stored separately.fragmenter(String fragmenter)
Sets what fragmenter to use to break up text that is eligible for highlighting.fragmentSize(Integer fragmentSize)
Set the fragment size in characters, defaults toHighlightBuilder.DEFAULT_FRAGMENT_CHAR_SIZE
int
hashCode()
highlighterType(String highlighterType)
Set type of highlighter to use.highlightFilter(Boolean highlightFilter)
Set this to true when using the highlighterTypefvh
and you want to provide highlighting on filter clauses in your query.highlightQuery(QueryBuilder highlightQuery)
Sets a query to be used for highlighting instead of the search query.protected abstract void
innerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder)
maxAnalyzedOffset(Integer maxAnalyzedOffset)
Set to a non-negative value which represents the max offset used to analyze the field thus avoiding exceptions if the field exceeds this limit.noMatchSize(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.numOfFragments(Integer numOfFragments)
Set the number of fragments, defaults toHighlightBuilder.DEFAULT_NUMBER_OF_FRAGMENTS
options()
Allows to set custom options for custom highlighters.order()
The order of fragments per field.order(HighlightBuilder.Order scoreOrdered)
By default, fragments of a field are ordered by the order in the highlighted text.phraseLimit(Integer phraseLimit)
Sets the maximum number of phrases the fvh will consider if the field doesn't also define phraseLimit.String[]
postTags()
Set the post tags that will be used for highlighting.String[]
preTags()
Set the pre tags that will be used for highlighting.requireFieldMatch(Boolean requireFieldMatch)
Set to true to cause a field to be highlighted only if a query matches that field.toString()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
writeTo(StreamOutput out)
write common parameters toStreamOutput
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.index.query.Rewriteable
rewrite
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
PRE_TAGS_FIELD
public static final org.elasticsearch.common.xcontent.ParseField PRE_TAGS_FIELD -
POST_TAGS_FIELD
public static final org.elasticsearch.common.xcontent.ParseField POST_TAGS_FIELD -
FIELDS_FIELD
public static final org.elasticsearch.common.xcontent.ParseField FIELDS_FIELD -
ORDER_FIELD
public static final org.elasticsearch.common.xcontent.ParseField ORDER_FIELD -
HIGHLIGHT_FILTER_FIELD
public static final org.elasticsearch.common.xcontent.ParseField HIGHLIGHT_FILTER_FIELD -
FRAGMENT_SIZE_FIELD
public static final org.elasticsearch.common.xcontent.ParseField FRAGMENT_SIZE_FIELD -
FRAGMENT_OFFSET_FIELD
public static final org.elasticsearch.common.xcontent.ParseField FRAGMENT_OFFSET_FIELD -
NUMBER_OF_FRAGMENTS_FIELD
public static final org.elasticsearch.common.xcontent.ParseField NUMBER_OF_FRAGMENTS_FIELD -
ENCODER_FIELD
public static final org.elasticsearch.common.xcontent.ParseField ENCODER_FIELD -
REQUIRE_FIELD_MATCH_FIELD
public static final org.elasticsearch.common.xcontent.ParseField REQUIRE_FIELD_MATCH_FIELD -
BOUNDARY_SCANNER_FIELD
public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_SCANNER_FIELD -
BOUNDARY_MAX_SCAN_FIELD
public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_MAX_SCAN_FIELD -
BOUNDARY_CHARS_FIELD
public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_CHARS_FIELD -
BOUNDARY_SCANNER_LOCALE_FIELD
public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_SCANNER_LOCALE_FIELD -
TYPE_FIELD
public static final org.elasticsearch.common.xcontent.ParseField TYPE_FIELD -
FRAGMENTER_FIELD
public static final org.elasticsearch.common.xcontent.ParseField FRAGMENTER_FIELD -
NO_MATCH_SIZE_FIELD
public static final org.elasticsearch.common.xcontent.ParseField NO_MATCH_SIZE_FIELD -
FORCE_SOURCE_FIELD
public static final org.elasticsearch.common.xcontent.ParseField FORCE_SOURCE_FIELD -
PHRASE_LIMIT_FIELD
public static final org.elasticsearch.common.xcontent.ParseField PHRASE_LIMIT_FIELD -
OPTIONS_FIELD
public static final org.elasticsearch.common.xcontent.ParseField OPTIONS_FIELD -
HIGHLIGHT_QUERY_FIELD
public static final org.elasticsearch.common.xcontent.ParseField HIGHLIGHT_QUERY_FIELD -
MATCHED_FIELDS_FIELD
public static final org.elasticsearch.common.xcontent.ParseField MATCHED_FIELDS_FIELD -
MAX_ANALYZED_OFFSET_FIELD
public static final org.elasticsearch.common.xcontent.ParseField MAX_ANALYZED_OFFSET_FIELD -
preTags
-
postTags
-
fragmentSize
-
numOfFragments
-
highlighterType
-
fragmenter
-
highlightQuery
-
order
-
highlightFilter
-
forceSource
-
boundaryScannerType
-
boundaryMaxScan
-
boundaryChars
protected char[] boundaryChars -
boundaryScannerLocale
-
noMatchSize
-
phraseLimit
-
options
-
requireFieldMatch
-
maxAnalyzedOffset
-
-
Constructor Details
-
AbstractHighlighterBuilder
public AbstractHighlighterBuilder() -
AbstractHighlighterBuilder
protected AbstractHighlighterBuilder(AbstractHighlighterBuilder<?> template, QueryBuilder queryBuilder) -
AbstractHighlighterBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
writeTo
write common parameters toStreamOutput
- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
doWriteTo
- Throws:
IOException
-
preTags
Set the pre tags that will be used for highlighting. -
preTags
- Returns:
- the value set by
preTags(String...)
-
postTags
Set the post tags that will be used for highlighting. -
postTags
- Returns:
- the value set by
postTags(String...)
-
fragmentSize
Set the fragment size in characters, defaults toHighlightBuilder.DEFAULT_FRAGMENT_CHAR_SIZE
-
fragmentSize
- Returns:
- the value set by
fragmentSize(Integer)
-
numOfFragments
Set the number of fragments, defaults toHighlightBuilder.DEFAULT_NUMBER_OF_FRAGMENTS
-
numOfFragments
- Returns:
- the value set by
numOfFragments(Integer)
-
highlighterType
Set type of highlighter to use. Out of the box supported types areunified
,plain
andfvh
. Defaults tounified
. Details of the different highlighter types are covered in the reference guide. -
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 toSimpleFragmenter
andSimpleSpanFragmenter
implementations respectively with the default being "span" -
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 highlighterTypefvh
and you want to provide highlighting on filter clauses in your query. Default isfalse
. -
highlightFilter
- Returns:
- the value set by
highlightFilter(Boolean)
-
boundaryScannerType
When using the highlighterTypefvh
this setting controls which scanner to use for fragment boundaries, and defaults to "simple". -
boundaryScannerType
When using the highlighterTypefvh
this 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 highlighterTypefvh
this setting controls how far to look for boundary characters, and defaults to 20. -
boundaryMaxScan
- Returns:
- the value set by
boundaryMaxScan(Integer)
-
boundaryChars
When using the highlighterTypefvh
this 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 highlighterTypefvh
and boundaryScannerTypebreak_iterator
, this setting controls the locale to use by the BreakIterator, defaults to "root". -
boundaryScannerLocale
- Returns:
- the value set by
boundaryScannerLocale(String)
-
options
Allows to set custom options for custom highlighters. -
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
- 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
- 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
- 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
- Returns:
- the value set by
forceSource(Boolean)
-
maxAnalyzedOffset
Set to a non-negative value which represents the max offset used to analyze the field thus avoiding exceptions if the field exceeds this limit. -
maxAnalyzedOffset
- Returns:
- the value set by
maxAnalyzedOffset(Integer)
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
IOException
-
innerXContent
protected abstract void innerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder) throws IOException- Throws:
IOException
-
hashCode
public final int hashCode() -
doHashCode
protected abstract int doHashCode()fields only present in subclass should contribute to hashCode in the implementation -
equals
-
doEquals
fields only present in subclass should be checked for equality in the implementation -
toString
-