org.elasticsearch.search.highlight
Class HighlightBuilder

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

public class HighlightBuilder
extends Object
implements ToXContent

A builder for search highlighting.

See Also:
SearchSourceBuilder.highlight()

Nested Class Summary
static class HighlightBuilder.Field
           
 
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 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 order(String order)
          The order of fragments per field.
 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)
           
 HighlightBuilder tagsSchema(String schemaName)
          Set a tag scheme that encapsulates a built in pre and post tags.
 XContentBuilder 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(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

Parameters:
name - The field to highlight

field

public 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.

Parameters:
name - The field to highlight
fragmentSize - The size of a fragment in characters

field

public 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.

Parameters:
name - The field to highlight
fragmentSize - The size of a fragment in characters
numberOfFragments - 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 highlight
fragmentSize - The size of a fragment in characters
numberOfFragments - The (maximum) number of fragments
fragmentOffset - The offset from the start of the fragment to the start of the highlight

field

public HighlightBuilder field(HighlightBuilder.Field field)

tagsSchema

public HighlightBuilder tagsSchema(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

encoder

public HighlightBuilder encoder(String encoder)
Set encoder for the highlighting are styled and default.

Parameters:
encoder - name

preTags

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


postTags

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


order

public HighlightBuilder order(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.


requireFieldMatch

public HighlightBuilder requireFieldMatch(boolean requireFieldMatch)

toXContent

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


Copyright © 2009-2012. All Rights Reserved.