Spring Data Solr

org.springframework.data.solr.core.query
Class HighlightOptions

java.lang.Object
  extended by org.springframework.data.solr.core.query.HighlightOptions

public class HighlightOptions
extends Object

Empty Options indicate to set hl=true. As long as there are no fields defined * will be used. Some options like setFormatter(String) can be set directly. Any option can be set via addHighlightParameter(HighlightParameter).

Author:
Christoph Strobl

Nested Class Summary
static class HighlightOptions.FieldWithHighlightParameters
          Field with hightlight query parameters
static class HighlightOptions.HighlightParameter
          Query Parameter to be used for highlighting
 
Field Summary
static Field ALL_FIELDS
           
 
Constructor Summary
HighlightOptions()
           
 
Method Summary
 HighlightOptions addField(Field field)
          Add field to highlight
 HighlightOptions addField(String... fieldnames)
          Add names of fields to highlight on
 HighlightOptions addField(String fieldname)
          Add name of field to highlight on
 HighlightOptions addFields(Collection<String> fieldnames)
          Add names of fields to highlight on
 HighlightOptions addHighlightParameter(HighlightOptions.HighlightParameter parameter)
          Add parameter
 HighlightOptions addHighlightParameter(String parameterName, Object value)
          Add parameter by name
 List<Field> getFields()
           
 Collection<HighlightOptions.FieldWithHighlightParameters> getFieldsWithHighlightParameters()
          Get Collection of fields that have field specific highlight options.
 String getFormatter()
           
 Integer getFragsize()
           
 Collection<HighlightOptions.HighlightParameter> getHighlightParameters()
           
<S> S
getHighlightParameterValue(String parameterName)
          Get value of parameter with given type
 Integer getNrSnipplets()
           
 FilterQuery getQuery()
           
 String getSimplePostfix()
           
 String getSimplePrefix()
           
 boolean hasFields()
           
 boolean hasQuery()
           
 HighlightOptions setFormatter(String formatter)
          set formatter hl.formatter
 HighlightOptions setFragsize(Integer fragsize)
          set fragsize hl.fragsize.
 HighlightOptions setNrSnipplets(Integer nrSnipplets)
          set hl.snippets
 HighlightOptions setQuery(FilterQuery query)
          Set FilterQuery to be used for hl.q
 HighlightOptions setSimplePostfix(String postfix)
          set hl.simple.post
 HighlightOptions setSimplePrefix(String prefix)
          set hl.simple.pre
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_FIELDS

public static final Field ALL_FIELDS
Constructor Detail

HighlightOptions

public HighlightOptions()
Method Detail

addField

public HighlightOptions addField(Field field)
Add field to highlight

Parameters:
field -
Returns:

addField

public HighlightOptions addField(String fieldname)
Add name of field to highlight on

Parameters:
fieldname -
Returns:

addField

public HighlightOptions addField(String... fieldnames)
Add names of fields to highlight on

Parameters:
fieldnames -
Returns:

addFields

public HighlightOptions addFields(Collection<String> fieldnames)
Add names of fields to highlight on

Parameters:
fieldnames -
Returns:

getQuery

public FilterQuery getQuery()
Returns:
null if not set

setQuery

public HighlightOptions setQuery(FilterQuery query)
Set FilterQuery to be used for hl.q

Parameters:
query -

getFragsize

public Integer getFragsize()
Returns:
null if not set

setFragsize

public HighlightOptions setFragsize(Integer fragsize)
set fragsize hl.fragsize.

Parameters:
fragsize -

getFormatter

public String getFormatter()
Returns:
null if not set

setFormatter

public HighlightOptions setFormatter(String formatter)
set formatter hl.formatter

Parameters:
formatter -

getNrSnipplets

public Integer getNrSnipplets()
Returns:
null if not set

setNrSnipplets

public HighlightOptions setNrSnipplets(Integer nrSnipplets)
set hl.snippets

Parameters:
nrSnipplets -

setSimplePrefix

public HighlightOptions setSimplePrefix(String prefix)
set hl.simple.pre

Parameters:
prefix -

getSimplePrefix

public String getSimplePrefix()
Returns:

setSimplePostfix

public HighlightOptions setSimplePostfix(String postfix)
set hl.simple.post

Parameters:
postfix -

getSimplePostfix

public String getSimplePostfix()
Returns:

getFields

public List<Field> getFields()
Returns:
unmodifiable list of fields

getHighlightParameters

public Collection<HighlightOptions.HighlightParameter> getHighlightParameters()
Returns:
collection of all parameters

addHighlightParameter

public HighlightOptions addHighlightParameter(String parameterName,
                                              Object value)
Add parameter by name

Parameters:
parameterName - must not be null
value -
Returns:

addHighlightParameter

public HighlightOptions addHighlightParameter(HighlightOptions.HighlightParameter parameter)
Add parameter

Parameters:
parameter - must not be null
Returns:

getHighlightParameterValue

public <S> S getHighlightParameterValue(String parameterName)
Get value of parameter with given type

Parameters:
parameterName -
Returns:
null if not present

getFieldsWithHighlightParameters

public Collection<HighlightOptions.FieldWithHighlightParameters> getFieldsWithHighlightParameters()
Get Collection of fields that have field specific highlight options.

Returns:

hasQuery

public boolean hasQuery()
Returns:
true if query is not null

hasFields

public boolean hasFields()
Returns:
true if at least one field available

Spring Data Solr

Copyright © 2011-2014-2014 Pivotal. All Rights Reserved.