Class AbstractHighlighterBuilder<HB extends AbstractHighlighterBuilder<?>>
- java.lang.Object
-
- org.elasticsearch.search.fetch.subphase.highlight.AbstractHighlighterBuilder<HB>
-
- All Implemented Interfaces:
Writeable
,ToXContent
,ToXContentObject
,Rewriteable<HB>
- Direct Known Subclasses:
HighlightBuilder
,HighlightBuilder.Field
public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterBuilder<?>> extends java.lang.Object implements Writeable, Rewriteable<HB>, ToXContentObject
This abstract class holds parameters shared byHighlightBuilder
andHighlightBuilder.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
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
-
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
Constructors Modifier Constructor Description AbstractHighlighterBuilder()
protected
AbstractHighlighterBuilder(StreamInput in)
Read from a stream.protected
AbstractHighlighterBuilder(AbstractHighlighterBuilder template, QueryBuilder queryBuilder)
-
Method Summary
Modifier and Type Method Description char[]
boundaryChars()
HB
boundaryChars(char[] boundaryChars)
When using the highlighterTypefvh
this setting defines what constitutes a boundary for highlighting.java.lang.Integer
boundaryMaxScan()
HB
boundaryMaxScan(java.lang.Integer boundaryMaxScan)
When using the highlighterTypefvh
this setting controls how far to look for boundary characters, and defaults to 20.java.util.Locale
boundaryScannerLocale()
HB
boundaryScannerLocale(java.lang.String boundaryScannerLocale)
When using the highlighterTypefvh
and boundaryScannerTypebreak_iterator
, this setting controls the locale to use by the BreakIterator, defaults to "root".HighlightBuilder.BoundaryScannerType
boundaryScannerType()
HB
boundaryScannerType(java.lang.String boundaryScannerType)
When using the highlighterTypefvh
this setting controls which scanner to use for fragment boundaries, and defaults to "simple".HB
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
doEquals(HB other)
fields only present in subclass should be checked for equality in the implementationprotected abstract int
doHashCode()
fields only present in subclass should contribute to hashCode in the implementationprotected abstract void
doWriteTo(StreamOutput out)
boolean
equals(java.lang.Object obj)
java.lang.Boolean
forceSource()
HB
forceSource(java.lang.Boolean forceSource)
Forces the highlighting to highlight fields based on the source even if fields are stored separately.java.lang.String
fragmenter()
HB
fragmenter(java.lang.String fragmenter)
Sets what fragmenter to use to break up text that is eligible for highlighting.java.lang.Integer
fragmentSize()
HB
fragmentSize(java.lang.Integer fragmentSize)
Set the fragment size in characters, defaults toHighlightBuilder.DEFAULT_FRAGMENT_CHAR_SIZE
int
hashCode()
java.lang.String
highlighterType()
HB
highlighterType(java.lang.String highlighterType)
Set type of highlighter to use.java.lang.Boolean
highlightFilter()
HB
highlightFilter(java.lang.Boolean highlightFilter)
Set this to true when using the highlighterTypefvh
and you want to provide highlighting on filter clauses in your query.QueryBuilder
highlightQuery()
HB
highlightQuery(QueryBuilder highlightQuery)
Sets a query to be used for highlighting instead of the search query.protected abstract void
innerXContent(XContentBuilder builder)
java.lang.Integer
noMatchSize()
HB
noMatchSize(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.Integer
numOfFragments()
HB
numOfFragments(java.lang.Integer numOfFragments)
Set the number of fragments, defaults toHighlightBuilder.DEFAULT_NUMBER_OF_FRAGMENTS
java.util.Map<java.lang.String,java.lang.Object>
options()
HB
options(java.util.Map<java.lang.String,java.lang.Object> options)
Allows to set custom options for custom highlighters.HighlightBuilder.Order
order()
HB
order(java.lang.String order)
The order of fragments per field.HB
order(HighlightBuilder.Order scoreOrdered)
By default, fragments of a field are ordered by the order in the highlighted text.java.lang.Integer
phraseLimit()
HB
phraseLimit(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()
HB
postTags(java.lang.String... postTags)
Set the post tags that will be used for highlighting.java.lang.String[]
preTags()
HB
preTags(java.lang.String... preTags)
Set the pre tags that will be used for highlighting.java.lang.Boolean
requireFieldMatch()
HB
requireFieldMatch(java.lang.Boolean requireFieldMatch)
Set to true to cause a field to be highlighted only if a query matches that field.java.lang.String
toString()
XContentBuilder
toXContent(XContentBuilder builder, 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 Detail
-
PRE_TAGS_FIELD
public static final ParseField PRE_TAGS_FIELD
-
POST_TAGS_FIELD
public static final ParseField POST_TAGS_FIELD
-
FIELDS_FIELD
public static final ParseField FIELDS_FIELD
-
ORDER_FIELD
public static final ParseField ORDER_FIELD
-
HIGHLIGHT_FILTER_FIELD
public static final ParseField HIGHLIGHT_FILTER_FIELD
-
FRAGMENT_SIZE_FIELD
public static final ParseField FRAGMENT_SIZE_FIELD
-
FRAGMENT_OFFSET_FIELD
public static final ParseField FRAGMENT_OFFSET_FIELD
-
NUMBER_OF_FRAGMENTS_FIELD
public static final ParseField NUMBER_OF_FRAGMENTS_FIELD
-
ENCODER_FIELD
public static final ParseField ENCODER_FIELD
-
REQUIRE_FIELD_MATCH_FIELD
public static final ParseField REQUIRE_FIELD_MATCH_FIELD
-
BOUNDARY_SCANNER_FIELD
public static final ParseField BOUNDARY_SCANNER_FIELD
-
BOUNDARY_MAX_SCAN_FIELD
public static final ParseField BOUNDARY_MAX_SCAN_FIELD
-
BOUNDARY_CHARS_FIELD
public static final ParseField BOUNDARY_CHARS_FIELD
-
BOUNDARY_SCANNER_LOCALE_FIELD
public static final ParseField BOUNDARY_SCANNER_LOCALE_FIELD
-
TYPE_FIELD
public static final ParseField TYPE_FIELD
-
FRAGMENTER_FIELD
public static final ParseField FRAGMENTER_FIELD
-
NO_MATCH_SIZE_FIELD
public static final ParseField NO_MATCH_SIZE_FIELD
-
FORCE_SOURCE_FIELD
public static final ParseField FORCE_SOURCE_FIELD
-
PHRASE_LIMIT_FIELD
public static final ParseField PHRASE_LIMIT_FIELD
-
OPTIONS_FIELD
public static final ParseField OPTIONS_FIELD
-
HIGHLIGHT_QUERY_FIELD
public static final ParseField HIGHLIGHT_QUERY_FIELD
-
MATCHED_FIELDS_FIELD
public static final 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
protected QueryBuilder highlightQuery
-
order
protected HighlightBuilder.Order order
-
highlightFilter
protected java.lang.Boolean highlightFilter
-
forceSource
protected java.lang.Boolean forceSource
-
boundaryScannerType
protected HighlightBuilder.BoundaryScannerType 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 Detail
-
AbstractHighlighterBuilder
public AbstractHighlighterBuilder()
-
AbstractHighlighterBuilder
protected AbstractHighlighterBuilder(AbstractHighlighterBuilder template, QueryBuilder queryBuilder)
-
AbstractHighlighterBuilder
protected AbstractHighlighterBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
writeTo
public final void writeTo(StreamOutput out) throws java.io.IOException
write common parameters toStreamOutput
-
doWriteTo
protected abstract void doWriteTo(StreamOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
preTags
public HB preTags(java.lang.String... 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
public HB postTags(java.lang.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
public HB fragmentSize(java.lang.Integer 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
public HB numOfFragments(java.lang.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
public HB highlighterType(java.lang.String highlighterType)
Set type of highlighter to use. Out of the box supported types areunified
,plain
andfvj
. 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
public HB fragmenter(java.lang.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
public java.lang.String fragmenter()
- Returns:
- the value set by
fragmenter(String)
-
highlightQuery
public HB highlightQuery(QueryBuilder highlightQuery)
Sets a query to be used for highlighting instead of the search query.
-
highlightQuery
public QueryBuilder highlightQuery()
- Returns:
- the value set by
highlightQuery(QueryBuilder)
-
order
public HB order(java.lang.String 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
public HB order(HighlightBuilder.Order scoreOrdered)
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
public HighlightBuilder.Order order()
- Returns:
- the value set by
order(Order)
-
highlightFilter
public HB highlightFilter(java.lang.Boolean highlightFilter)
Set this to true when using the highlighterTypefvh
and 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
public HB boundaryScannerType(java.lang.String boundaryScannerType)
When using the highlighterTypefvh
this setting controls which scanner to use for fragment boundaries, and defaults to "simple".
-
boundaryScannerType
public HB boundaryScannerType(HighlightBuilder.BoundaryScannerType boundaryScannerType)
When using the highlighterTypefvh
this setting controls which scanner to use for fragment boundaries, and defaults to "simple".
-
boundaryScannerType
public HighlightBuilder.BoundaryScannerType boundaryScannerType()
- Returns:
- the value set by
boundaryScannerType(String)
-
boundaryMaxScan
public HB boundaryMaxScan(java.lang.Integer boundaryMaxScan)
When using the highlighterTypefvh
this 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
public HB boundaryChars(char[] 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
public HB boundaryScannerLocale(java.lang.String boundaryScannerLocale)
When using the highlighterTypefvh
and 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
public HB options(java.util.Map<java.lang.String,java.lang.Object> 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
public HB requireFieldMatch(java.lang.Boolean 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
public HB noMatchSize(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.- 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
public HB phraseLimit(java.lang.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
public HB forceSource(java.lang.Boolean 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 XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
innerXContent
protected abstract void innerXContent(XContentBuilder builder) throws java.io.IOException
- Throws:
java.io.IOException
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in 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:
equals
in classjava.lang.Object
-
doEquals
protected abstract boolean doEquals(HB other)
fields only present in subclass should be checked for equality in the implementation
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-