public final class SolrQueryUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ESCAPE_CHARS
chars, that if part of a term need to be escaped when searching.
|
static java.lang.String |
ESCAPE_CHARS_WS
chars, that if part of a term need to be escaped when searching. including space
|
static java.lang.String |
OR_SEPARATOR
Lucene/Solr operator for OR query parts.
|
static java.lang.String |
QUERY_WRAPPER_FILTER
The query wrapper filter string.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
appendFieldQueryPart(java.lang.StringBuilder q,
java.lang.String field,
java.util.List<Value> values) |
static java.lang.String |
decodeQuery(java.lang.String query) |
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. escaping fo chars and
wrapping in quotes
|
static java.lang.String |
toSolrQueryFilter(java.lang.String filter)
Convert a lucene QueryWrapperFilter to a query filter for solr.
|
static java.lang.String |
toTokenQueryOnField(java.lang.String fieldName,
java.lang.String token)
returns an escaped query string of the form
(<field>:<token>). |
public static final java.lang.String OR_SEPARATOR
public static final java.lang.String QUERY_WRAPPER_FILTER
public static final java.lang.String ESCAPE_CHARS
public static final java.lang.String ESCAPE_CHARS_WS
public static void appendFieldQueryPart(java.lang.StringBuilder q,
java.lang.String field,
java.util.List<Value> values)
q - the query to add the field query part to.field - the field name to add the query part forvalues - the field value alternatives to match in the searchpublic static java.lang.String encodeQuery(java.lang.String query)
throws java.io.UnsupportedEncodingException
query - the query.java.io.UnsupportedEncodingException - UnsupportedEncodingException.public static java.lang.String decodeQuery(java.lang.String query)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptionpublic static java.lang.String escapeQuery(java.lang.String query)
query - the query.ESCAPE_CHARS,
toConstQueryOnField(String, String)public static java.lang.String escapeQuery(java.lang.String query,
java.lang.String escapeChars)
query - the query, if empty nothing happens and it is returned as is.escapeChars - the chars to escapepublic static boolean responseStatusIsError(SolrResponseBase response)
throws SolrServerException
SolrServerExceptionhttp://lucene.472066.n3.nabble.com/Response-status-td490876.htmlpublic static java.lang.String toSolrQueryFilter(java.lang.String filter)
filter - the filter.public static java.lang.String toConstQueryOnField(java.lang.String fieldName,
java.lang.String constant)
fieldName - must not contain whitespace, but this is not checked!constant - the constantpublic static java.lang.String toTokenQueryOnField(java.lang.String fieldName,
java.lang.String token)
(<field>:<token>). The given token is fully escaped, i.e.
including spaces.