Module org.elasticsearch.server
Class HighlightBuilder
java.lang.Object
org.elasticsearch.search.fetch.subphase.highlight.AbstractHighlighterBuilder<HighlightBuilder>
org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder
- All Implemented Interfaces:
Writeable,Rewriteable<HighlightBuilder>,ToXContent,ToXContentObject
A builder for search highlighting. Settings can control how large fields
are summarized to show only selected snippets ("fragments") containing search terms.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final classstatic enumNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringthe default encoder settingstatic final intthe default number of fragments size in charactersstatic final booleandefault for whetherfvhshould provide highlighting on filter clausesstatic final Integerdefault for whether to stop highlighting at the defined max_analyzed_offset to avoid exceptions for longer textsstatic final intdefault for fragment size when there are no matchesstatic final intthe default number of fragments for highlightingstatic final intdefault for the maximum number of phrases the fvh will considerstatic final booleandefault for whether a field should be highlighted only if a query matches that fieldstatic final booleandefault for highlight fragments being ordered by scorestatic final String[]the default closing tags whentag_schema = "styled"static final String[]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, ENCODER_FIELD, FIELDS_FIELD, FORCE_SOURCE_FIELD, 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, TAGS_SCHEMA_FIELD, TYPE_FIELDFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionRead from a stream.HighlightBuilder(HighlightBuilder template, QueryBuilder highlightQuery, List<HighlightBuilder.Field> fields) -
Method Summary
Modifier and TypeMethodDescriptionbuild(SearchExecutionContext context) protected booleandoEquals(HighlightBuilder other) fields only present in subclass should be checked for equality in the implementationprotected intfields only present in subclass should contribute to hashCode in the implementationprotected voiddoWriteTo(StreamOutput out) Adds a field to be highlighted with default fragment size of 100 characters, and default number of fragments of 5 using the default encoderAdds a field to be highlighted with a provided fragment size (in characters), and a provided (maximum) number of fragments.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 HighlightBuildervoidinnerXContent(XContentBuilder builder) Rewrites this instance based on the provided context.toXContent(XContentBuilder builder, 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, boundaryScannerType, boundaryScannerType, boundaryScannerType, encoder, encoder, equals, 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, tagsSchema, toString, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
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:
-
DEFAULT_MAX_ANALYZED_OFFSET
default 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 whetherfvhshould provide highlighting on filter clauses- See Also:
-
DEFAULT_SCORE_ORDERED
public static final boolean DEFAULT_SCORE_ORDEREDdefault for highlight fragments being ordered by score- See Also:
-
DEFAULT_ENCODER
the default encoder setting- See Also:
-
DEFAULT_PHRASE_LIMIT
public static final int DEFAULT_PHRASE_LIMITdefault for the maximum number of phrases the fvh will consider- See Also:
-
DEFAULT_NO_MATCH_SIZE
public static final int DEFAULT_NO_MATCH_SIZEdefault for fragment size when there are no matches- See Also:
-
DEFAULT_NUMBER_OF_FRAGMENTS
public static final int DEFAULT_NUMBER_OF_FRAGMENTSthe default number of fragments for highlighting- See Also:
-
DEFAULT_FRAGMENT_CHAR_SIZE
public static final int DEFAULT_FRAGMENT_CHAR_SIZEthe default number of fragments size in characters- See Also:
-
DEFAULT_STYLED_PRE_TAG
the default opening tags whentag_schema = "styled" -
DEFAULT_STYLED_POST_TAGS
the default closing tags whentag_schema = "styled"
-
-
Constructor Details
-
HighlightBuilder
public HighlightBuilder() -
HighlightBuilder
public HighlightBuilder(HighlightBuilder template, QueryBuilder highlightQuery, List<HighlightBuilder.Field> fields) -
HighlightBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractHighlighterBuilder<HighlightBuilder>- Throws:
IOException
-
field
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
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 HighlightBuilder field(String 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
-
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
Gets value set withuseExplicitFieldOrder(boolean) -
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Overrides:
toXContentin classAbstractHighlighterBuilder<HighlightBuilder>- Throws:
IOException
-
fromXContent
-
build
- Throws:
IOException
-
innerXContent
- Specified by:
innerXContentin classAbstractHighlighterBuilder<HighlightBuilder>- Throws:
IOException
-
doHashCode
protected int doHashCode()Description copied from class:AbstractHighlighterBuilderfields only present in subclass should contribute to hashCode in the implementation- Specified by:
doHashCodein classAbstractHighlighterBuilder<HighlightBuilder>
-
doEquals
Description copied from class:AbstractHighlighterBuilderfields only present in subclass should be checked for equality in the implementation- Specified by:
doEqualsin classAbstractHighlighterBuilder<HighlightBuilder>
-
rewrite
Description copied from interface:RewriteableRewrites 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:
IOException
-