public class HighlightBuilder extends Object implements ToXContent
SearchSourceBuilder.highlight()
Modifier and Type | Class and Description |
---|---|
static class |
HighlightBuilder.Field |
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
EMPTY_PARAMS
Constructor and Description |
---|
HighlightBuilder() |
Modifier and Type | Method and Description |
---|---|
HighlightBuilder |
boundaryChars(char[] boundaryChars)
When using the highlighterType fast-vector-highlighter this setting
defines what constitutes a boundary for highlighting.
|
HighlightBuilder |
boundaryMaxScan(Integer boundaryMaxScan)
When using the highlighterType fast-vector-highlighter this setting
controls how far to look for boundary characters, and defaults to 20.
|
HighlightBuilder |
encoder(String encoder)
Set encoder for the highlighting
are styled and default.
|
HighlightBuilder |
field(HighlightBuilder.Field field) |
HighlightBuilder |
field(String 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
|
HighlightBuilder |
field(String name,
int fragmentSize)
Adds a field to be highlighted with a provided fragment size (in characters), and
default number of fragments of 5.
|
HighlightBuilder |
field(String 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.
|
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.
|
HighlightBuilder |
forceSource(boolean forceSource)
Forces the highlighting to highlight fields based on the source even if fields are stored separately.
|
HighlightBuilder |
fragmenter(String fragmenter)
Sets what fragmenter to use to break up text that is eligible for highlighting.
|
HighlightBuilder |
fragmentSize(Integer fragmentSize)
Sets the size of a fragment in characters (defaults to 100)
|
HighlightBuilder |
highlighterType(String highlighterType)
Set type of highlighter to use.
|
HighlightBuilder |
highlightFilter(boolean highlightFilter)
Set this to true when using the highlighterType fast-vector-highlighter
and you want to provide highlighting on filter clauses in your
query.
|
HighlightBuilder |
highlightQuery(QueryBuilder highlightQuery)
Sets a query to be used for highlighting all fields instead of the search query.
|
HighlightBuilder |
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.
|
HighlightBuilder |
numOfFragments(Integer numOfFragments)
Sets the maximum number of fragments returned
|
HighlightBuilder |
options(Map<String,Object> options)
Allows to set custom options for custom highlighters.
|
HighlightBuilder |
order(String order)
The order of fragments per field.
|
HighlightBuilder |
phraseLimit(Integer phraseLimit)
Sets the maximum number of phrases the fvh will consider if the field doesn't also define phraseLimit.
|
HighlightBuilder |
postTags(String... postTags)
Explicitly set the post tags that will be used for highlighting.
|
HighlightBuilder |
preTags(String... preTags)
Explicitly set the pre tags that will be used for highlighting.
|
HighlightBuilder |
requireFieldMatch(boolean requireFieldMatch)
Set to true to cause a field to be highlighted only if a query matches that field.
|
HighlightBuilder |
tagsSchema(String schemaName)
Set a tag scheme that encapsulates a built in pre and post tags.
|
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
HighlightBuilder |
useExplicitFieldOrder(boolean useExplicitFieldOrder)
Send the fields to be highlighted using a syntax that is specific about the order in which they should be highlighted.
|
public HighlightBuilder field(String name)
name
- The field to highlightpublic HighlightBuilder field(String name, int fragmentSize)
name
- The field to highlightfragmentSize
- The size of a fragment in characterspublic HighlightBuilder field(String name, int fragmentSize, int numberOfFragments)
name
- The field to highlightfragmentSize
- The size of a fragment in charactersnumberOfFragments
- The (maximum) number of fragmentspublic HighlightBuilder field(String name, int fragmentSize, int numberOfFragments, int fragmentOffset)
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 highlightpublic HighlightBuilder field(HighlightBuilder.Field field)
public HighlightBuilder tagsSchema(String schemaName)
schemaName
- The tag scheme namepublic HighlightBuilder highlightFilter(boolean highlightFilter)
public HighlightBuilder fragmentSize(Integer fragmentSize)
public HighlightBuilder numOfFragments(Integer numOfFragments)
public HighlightBuilder encoder(String encoder)
encoder
- namepublic HighlightBuilder preTags(String... preTags)
public HighlightBuilder postTags(String... postTags)
public HighlightBuilder order(String order)
public HighlightBuilder requireFieldMatch(boolean requireFieldMatch)
public HighlightBuilder boundaryMaxScan(Integer boundaryMaxScan)
public HighlightBuilder boundaryChars(char[] boundaryChars)
public HighlightBuilder highlighterType(String highlighterType)
public HighlightBuilder fragmenter(String fragmenter)
SimpleFragmenter
and
SimpleSpanFragmenter
implementations respectively with the default being "span"public HighlightBuilder highlightQuery(QueryBuilder highlightQuery)
public HighlightBuilder noMatchSize(Integer noMatchSize)
noMatchSize
- integer to set or null to leave out of request. default is null.public HighlightBuilder phraseLimit(Integer phraseLimit)
phraseLimit
- maximum number of phrases the fvh will considerpublic HighlightBuilder options(Map<String,Object> options)
public HighlightBuilder forceSource(boolean forceSource)
public HighlightBuilder useExplicitFieldOrder(boolean useExplicitFieldOrder)
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
toXContent
in interface ToXContent
IOException
Copyright © 2009–2016. All rights reserved.