SMILA (incubation) API documentation

org.eclipse.smila.solr.util
Class SolrUtils

java.lang.Object
  extended by org.eclipse.smila.solr.util.SolrUtils

public final class SolrUtils
extends java.lang.Object

SolrUtils class.


Field Summary
static java.lang.String ESCAPE_CHARS
          chars, that if part of a term need to be escaped when searching.
 
Constructor Summary
SolrUtils()
           
 
Method Summary
static java.lang.String encodeQuery(java.lang.String query)
          Encode a query into application/x-www-form-urlencoded format.
static java.lang.String escapeQuery(java.lang.String query)
          Escapes all chars with a special meaning to the lucene query parser.
static java.lang.String escapeQuery(java.lang.String query, java.lang.String escapeChars)
          Escapes the given chars in the given query by prepending '\'.
static boolean responseStatusIsError(SolrResponseBase response)
          returns true if response indicates an error
static java.lang.String toConstQueryOnField(java.lang.String fieldName, java.lang.String constant)
          creates a query string on the given field for a constant which must be searched "as is", i.e.
static java.lang.String toSolrQueryFilter(java.lang.String filter)
          Convert a lucene QueryWrapperFilter to a query filter for solr.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ESCAPE_CHARS

public static final java.lang.String ESCAPE_CHARS
chars, that if part of a term need to be escaped when searching.

See Also:
Constant Field Values
Constructor Detail

SolrUtils

public SolrUtils()
Method Detail

encodeQuery

public static java.lang.String encodeQuery(java.lang.String query)
                                    throws java.io.UnsupportedEncodingException
Encode a query into application/x-www-form-urlencoded format.

Parameters:
query - the query.
Returns:
the urlencoded query.
Throws:
java.io.UnsupportedEncodingException - UnsupportedEncodingException.

escapeQuery

public static java.lang.String escapeQuery(java.lang.String query)
Escapes all chars with a special meaning to the lucene query parser. Spaces are not escaped.

Parameters:
query - the query.
Returns:
the query after escaping.
See Also:
ESCAPE_CHARS, toConstQueryOnField(String, String)

escapeQuery

public static java.lang.String escapeQuery(java.lang.String query,
                                           java.lang.String escapeChars)
Escapes the given chars in the given query by prepending '\'.

Parameters:
query - the query, if empty nothing happens and it is returned as is.
escapeChars - the chars to escape
Returns:
the string

responseStatusIsError

public static boolean responseStatusIsError(SolrResponseBase response)
                                     throws SolrServerException
returns true if response indicates an error

Throws:
SolrServerException
See Also:
http://lucene.472066.n3.nabble.com/Response-status-td490876.html

toSolrQueryFilter

public static java.lang.String toSolrQueryFilter(java.lang.String filter)
Convert a lucene QueryWrapperFilter to a query filter for solr.

Parameters:
filter - the filter.
Returns:
the solr query filter.

toConstQueryOnField

public static java.lang.String toConstQueryOnField(java.lang.String fieldName,
                                                   java.lang.String constant)
creates a query string on the given field for a constant which must be searched "as is", i.e. escaping fo chars and wrapping in quotes

Parameters:
fieldName - must not contain whitespace, but this is not checked!
constant - the constant
Returns:
the lucen query string

SMILA (incubation) API documentation