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.Params
Nested 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.ParseField
BOUNDARY_CHARS_FIELD
static org.elasticsearch.common.ParseField
BOUNDARY_MAX_SCAN_FIELD
static org.elasticsearch.common.ParseField
BOUNDARY_SCANNER_FIELD
static org.elasticsearch.common.ParseField
BOUNDARY_SCANNER_LOCALE_FIELD
protected char[]
boundaryChars
protected java.lang.Integer
boundaryMaxScan
protected java.util.Locale
boundaryScannerLocale
protected HighlightBuilder.BoundaryScannerType
boundaryScannerType
static org.elasticsearch.common.ParseField
ENCODER_FIELD
static org.elasticsearch.common.ParseField
FIELDS_FIELD
static org.elasticsearch.common.ParseField
FORCE_SOURCE_FIELD
protected java.lang.Boolean
forceSource
static org.elasticsearch.common.ParseField
FRAGMENT_OFFSET_FIELD
static org.elasticsearch.common.ParseField
FRAGMENT_SIZE_FIELD
protected java.lang.String
fragmenter
static org.elasticsearch.common.ParseField
FRAGMENTER_FIELD
protected java.lang.Integer
fragmentSize
static org.elasticsearch.common.ParseField
HIGHLIGHT_FILTER_FIELD
static org.elasticsearch.common.ParseField
HIGHLIGHT_QUERY_FIELD
protected java.lang.String
highlighterType
protected java.lang.Boolean
highlightFilter
protected QueryBuilder
highlightQuery
static org.elasticsearch.common.ParseField
MATCHED_FIELDS_FIELD
static org.elasticsearch.common.ParseField
NO_MATCH_SIZE_FIELD
protected java.lang.Integer
noMatchSize
static org.elasticsearch.common.ParseField
NUMBER_OF_FRAGMENTS_FIELD
protected java.lang.Integer
numOfFragments
protected java.util.Map<java.lang.String,java.lang.Object>
options
static org.elasticsearch.common.ParseField
OPTIONS_FIELD
protected HighlightBuilder.Order
order
static org.elasticsearch.common.ParseField
ORDER_FIELD
static org.elasticsearch.common.ParseField
PHRASE_LIMIT_FIELD
protected java.lang.Integer
phraseLimit
static org.elasticsearch.common.ParseField
POST_TAGS_FIELD
protected java.lang.String[]
postTags
static org.elasticsearch.common.ParseField
PRE_TAGS_FIELD
protected java.lang.String[]
preTags
static org.elasticsearch.common.ParseField
REQUIRE_FIELD_MATCH_FIELD
protected java.lang.Boolean
requireFieldMatch
static org.elasticsearch.common.ParseField
TYPE_FIELD
-
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(org.elasticsearch.common.xcontent.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()
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
-
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
,plain
andfvh
. 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 toSimpleFragmenter
andSimpleSpanFragmenter
implementations 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 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
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
public java.lang.Integer 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
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:
toXContent
in 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:
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
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
-