Class HighlightBuilder
org.elasticsearch.search.fetch.subphase.highlight.AbstractHighlighterBuilder<HighlightBuilder>
org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder
- All Implemented Interfaces:
Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
,Rewriteable<HighlightBuilder>
A builder for search highlighting. Settings can control how large fields
are summarized to show only selected snippets ("fragments") containing search terms.
- See Also:
SearchSourceBuilder.highlight()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
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
FieldsModifier and TypeFieldDescriptionstatic
the default encoder settingstatic boolean
default for whether to highlight fields based on the source even if stored separatelystatic int
the default number of fragments size in charactersstatic boolean
default for whetherfvh
should provide highlighting on filter clausesstatic
default for whether to stop highlighting at the defined max_analyzed_offset to avoid exceptions for longer textsstatic int
default for fragment size when there are no matchesstatic int
the default number of fragments for highlightingstatic int
default for the maximum number of phrases the fvh will considerstatic boolean
default for whether a field should be highlighted only if a query matches that fieldstatic boolean
default for highlight fragments being ordered by scorestatic []
the default closing tags whentag_schema = "styled"
static []
the default opening tags whentag_schema = "styled"
Fields inherited from class org.elasticsearch.search.fetch.subphase.highlight.AbstractHighlighterBuilder
BOUNDARY_CHARS_FIELD, BOUNDARY_MAX_SCAN_FIELD, BOUNDARY_SCANNER_FIELD, BOUNDARY_SCANNER_LOCALE_FIELD, boundaryChars, boundaryMaxScan, boundaryScannerLocale, boundaryScannerType, ENCODER_FIELD, FIELDS_FIELD, FORCE_SOURCE_FIELD, forceSource, FRAGMENT_OFFSET_FIELD, FRAGMENT_SIZE_FIELD, fragmenter, FRAGMENTER_FIELD, fragmentSize, HIGHLIGHT_FILTER_FIELD, HIGHLIGHT_QUERY_FIELD, highlighterType, highlightFilter, highlightQuery, MATCHED_FIELDS_FIELD, MAX_ANALYZED_OFFSET_FIELD, maxAnalyzedOffset, NO_MATCH_SIZE_FIELD, noMatchSize, NUMBER_OF_FRAGMENTS_FIELD, numOfFragments, options, OPTIONS_FIELD, order, ORDER_FIELD, PHRASE_LIMIT_FIELD, phraseLimit, POST_TAGS_FIELD, postTags, PRE_TAGS_FIELD, preTags, REQUIRE_FIELD_MATCH_FIELD, requireFieldMatch, TYPE_FIELD
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
ConstructorsConstructorDescriptionRead from a stream.HighlightBuilder(HighlightBuilder template, QueryBuilder highlightQuery, <HighlightBuilder.Field> fields)
-
Method Summary
Modifier and TypeMethodDescriptionbuild(SearchExecutionContext context)
protected boolean
doEquals(HighlightBuilder other)
fields only present in subclass should be checked for equality in the implementationprotected int
fields only present in subclass should contribute to hashCode in the implementationprotected void
doWriteTo(StreamOutput out)
encoder()
Getter forencoder(String)
encoder)
Set encoder for the highlighting arehtml
anddefault
.name)
Adds a field to be highlighted with default fragment size of 100 characters, and default number of fragments of 5 using the default encodername, int fragmentSize)
Adds a field to be highlighted with a provided fragment size (in characters), and default number of fragments of 5.name, int fragmentSize, int numberOfFragments)
Adds a field to be highlighted with a provided fragment size (in characters), and a provided (maximum) number of fragments.name, int fragmentSize, int numberOfFragments, int fragmentOffset)
Adds a field to be highlighted with a provided fragment size (in characters), and a provided (maximum) number of fragments.field(HighlightBuilder.Field field)
fields()
static HighlightBuilder
fromXContent(org.elasticsearch.common.xcontent.XContentParser p)
void
innerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder)
rewrite(QueryRewriteContext ctx)
Rewrites this instance based on the provided context.schemaName)
Set a tag scheme that encapsulates a built in pre and post tags.org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
Gets value set withuseExplicitFieldOrder(boolean)
useExplicitFieldOrder(boolean useExplicitFieldOrder)
Send the fields to be highlighted using a syntax that is specific about the order in which they should be highlighted.Methods inherited from class org.elasticsearch.search.fetch.subphase.highlight.AbstractHighlighterBuilder
boundaryChars, boundaryChars, boundaryMaxScan, boundaryMaxScan, boundaryScannerLocale, boundaryScannerLocale, boundaryScannerType, boundaryScannerType, boundaryScannerType, equals, forceSource, forceSource, fragmenter, fragmenter, fragmentSize, fragmentSize, hashCode, highlighterType, highlighterType, highlightFilter, highlightFilter, highlightQuery, highlightQuery, maxAnalyzedOffset, maxAnalyzedOffset, noMatchSize, noMatchSize, numOfFragments, numOfFragments, options, options, order, order, order, phraseLimit, phraseLimit, postTags, postTags, preTags, preTags, requireFieldMatch, requireFieldMatch, toString, writeTo
Methods inherited from class java.lang.
, , , , , , ,
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
DEFAULT_FORCE_SOURCE
public static final boolean DEFAULT_FORCE_SOURCEdefault for whether to highlight fields based on the source even if stored separately- See Also:
- Constant Field Values
-
DEFAULT_REQUIRE_FIELD_MATCH
public static final boolean DEFAULT_REQUIRE_FIELD_MATCHdefault for whether a field should be highlighted only if a query matches that field- See Also:
- Constant Field Values
-
DEFAULT_MAX_ANALYZED_OFFSET
public static final DEFAULT_MAX_ANALYZED_OFFSETdefault for whether to stop highlighting at the defined max_analyzed_offset to avoid exceptions for longer texts -
DEFAULT_HIGHLIGHT_FILTER
public static final boolean DEFAULT_HIGHLIGHT_FILTERdefault for whetherfvh
should provide highlighting on filter clauses- See Also:
- Constant Field Values
-
DEFAULT_SCORE_ORDERED
public static final boolean DEFAULT_SCORE_ORDEREDdefault for highlight fragments being ordered by score- See Also:
- Constant Field Values
-
DEFAULT_ENCODER
public static final DEFAULT_ENCODERthe default encoder setting- See Also:
- Constant Field Values
-
DEFAULT_PHRASE_LIMIT
public static final int DEFAULT_PHRASE_LIMITdefault for the maximum number of phrases the fvh will consider- See Also:
- Constant Field Values
-
DEFAULT_NO_MATCH_SIZE
public static final int DEFAULT_NO_MATCH_SIZEdefault for fragment size when there are no matches- See Also:
- Constant Field Values
-
DEFAULT_NUMBER_OF_FRAGMENTS
public static final int DEFAULT_NUMBER_OF_FRAGMENTSthe default number of fragments for highlighting- See Also:
- Constant Field Values
-
DEFAULT_FRAGMENT_CHAR_SIZE
public static final int DEFAULT_FRAGMENT_CHAR_SIZEthe default number of fragments size in characters- See Also:
- Constant Field Values
-
DEFAULT_STYLED_PRE_TAG
public static final [] DEFAULT_STYLED_PRE_TAGthe default opening tags whentag_schema = "styled"
-
DEFAULT_STYLED_POST_TAGS
public static final [] DEFAULT_STYLED_POST_TAGSthe default closing tags whentag_schema = "styled"
-
-
Constructor Details
-
HighlightBuilder
public HighlightBuilder() -
HighlightBuilder
public HighlightBuilder(HighlightBuilder template, QueryBuilder highlightQuery, <HighlightBuilder.Field> fields) -
HighlightBuilder
Read from a stream.- Throws:
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteTo
in classAbstractHighlighterBuilder<HighlightBuilder>
- Throws:
-
field
public name)Adds a field to be highlighted with default fragment size of 100 characters, and default number of fragments of 5 using the default encoder- Parameters:
name
- The field to highlight
-
field
public name, int fragmentSize)Adds a field to be highlighted with a provided fragment size (in characters), and default number of fragments of 5.- Parameters:
name
- The field to highlightfragmentSize
- The size of a fragment in characters
-
field
public name, int fragmentSize, int numberOfFragments)Adds a field to be highlighted with a provided fragment size (in characters), and a provided (maximum) number of fragments.- Parameters:
name
- The field to highlightfragmentSize
- The size of a fragment in charactersnumberOfFragments
- The (maximum) number of fragments
-
field
public name, int fragmentSize, int numberOfFragments, int fragmentOffset)Adds a field to be highlighted with a provided fragment size (in characters), and a provided (maximum) number of fragments.- Parameters:
name
- The field to highlightfragmentSize
- The size of a fragment in charactersnumberOfFragments
- The (maximum) number of fragmentsfragmentOffset
- The offset from the start of the fragment to the start of the highlight
-
field
-
fields
-
tagsSchema
public schemaName)Set a tag scheme that encapsulates a built in pre and post tags. The allowed schemes arestyled
anddefault
.- Parameters:
schemaName
- The tag scheme name
-
encoder
public encoder)Set encoder for the highlighting arehtml
anddefault
.- Parameters:
encoder
- name
-
encoder
public encoder()Getter forencoder(String)
-
useExplicitFieldOrder
Send the fields to be highlighted using a syntax that is specific about the order in which they should be highlighted.- Returns:
- this for chaining
-
useExplicitFieldOrder
public useExplicitFieldOrder()Gets value set withuseExplicitFieldOrder(boolean)
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Overrides:
toXContent
in classAbstractHighlighterBuilder<HighlightBuilder>
- Throws:
-
fromXContent
-
build
- Throws:
-
innerXContent
public void innerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder) throws- Specified by:
innerXContent
in classAbstractHighlighterBuilder<HighlightBuilder>
- Throws:
-
doHashCode
protected int doHashCode()Description copied from class:AbstractHighlighterBuilder
fields only present in subclass should contribute to hashCode in the implementation- Specified by:
doHashCode
in classAbstractHighlighterBuilder<HighlightBuilder>
-
doEquals
Description copied from class:AbstractHighlighterBuilder
fields only present in subclass should be checked for equality in the implementation- Specified by:
doEquals
in classAbstractHighlighterBuilder<HighlightBuilder>
-
rewrite
Description copied from interface:Rewriteable
Rewrites this instance based on the provided context. The returned objects will be the same instance as this if no changes during the rewrite were applied.- Throws:
-