org.elasticsearch.search.highlight
Class HighlightBuilder

java.lang.Object
  extended by org.elasticsearch.search.highlight.HighlightBuilder
All Implemented Interfaces:
ToXContent

public class HighlightBuilder
extends java.lang.Object
implements ToXContent

A builder for search highlighting.

See Also:
SearchSourceBuilder.highlight()

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.MapParams, ToXContent.Params
 
Field Summary
 
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
 
Constructor Summary
HighlightBuilder()
           
 
Method Summary
 HighlightBuilder field(java.lang.String name)
          Adds a field to be highlighted with default fragment size of 100 characters, and default number of fragments of 5.
 HighlightBuilder field(java.lang.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(java.lang.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 order(java.lang.String order)
          The order of fragments per field.
 HighlightBuilder postTags(java.lang.String... postTags)
          Explicitly set the post tags that will be used for highlighting.
 HighlightBuilder preTags(java.lang.String... preTags)
          Explicitly set the pre tags that will be used for highlighting.
 HighlightBuilder tagsSchema(java.lang.String schemaName)
          Set a tag scheme that encapsulates a built in pre and post tags.
 void toXContent(XContentBuilder builder, ToXContent.Params params)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighlightBuilder

public HighlightBuilder()
Method Detail

field

public HighlightBuilder field(java.lang.String name)
Adds a field to be highlighted with default fragment size of 100 characters, and default number of fragments of 5.

Parameters:
name - The field to highlight

field

public HighlightBuilder field(java.lang.String 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 highlight
fragmentSize - The size of a fragment in characters

field

public HighlightBuilder field(java.lang.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.

Parameters:
name - The field to highlight
fragmentSize - The size of a fragment in characters
numberOfFragments - The (maximum) number of fragments

tagsSchema

public HighlightBuilder tagsSchema(java.lang.String schemaName)
Set a tag scheme that encapsulates a built in pre and post tags. The allows schemes are styled and default.

Parameters:
schemaName - The tag scheme name

preTags

public HighlightBuilder preTags(java.lang.String... preTags)
Explicitly set the pre tags that will be used for highlighting.


postTags

public HighlightBuilder postTags(java.lang.String... postTags)
Explicitly set the post tags that will be used for highlighting.


order

public HighlightBuilder order(java.lang.String order)
The order of fragments per field. By default, ordered by the order in the highlighted text. Can be score, which then it will be ordered by score of the fragments.


toXContent

public void toXContent(XContentBuilder builder,
                       ToXContent.Params params)
                throws java.io.IOException
Specified by:
toXContent in interface ToXContent
Throws:
java.io.IOException