public class QueryParsing extends Object
Modifier and Type | Class and Description |
---|---|
static class |
QueryParsing.StrParser
Simple class to help with parsing a string
Note: This API is experimental and may change in non backward-compatible ways in the future
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFTYPE |
static String |
DOCID |
static String |
F |
static char |
LOCALPARAM_END |
static String |
LOCALPARAM_START |
static String |
OP |
static String |
SCORE |
static String |
TYPE |
static String |
V |
static String |
VAL_EXPLICIT |
Constructor and Description |
---|
QueryParsing() |
Modifier and Type | Method and Description |
---|---|
static String |
encodeLocalParamVal(String val) |
static SolrParams |
getLocalParams(String txt,
SolrParams params)
"foo" returns null
"{!
|
static FunctionQuery |
parseFunction(String func,
IndexSchema schema)
Parse a function, returning a FunctionQuery
Syntax Examples....
|
static Query |
parseQuery(String qs,
IndexSchema schema)
Helper utility for parsing a query using the Lucene QueryParser syntax.
|
static Query |
parseQuery(String qs,
String defaultField,
IndexSchema schema)
Helper utility for parsing a query using the Lucene QueryParser syntax.
|
static Query |
parseQuery(String qs,
String defaultField,
SolrParams params,
IndexSchema schema)
Helper utility for parsing a query using the Lucene QueryParser syntax.
|
static Sort |
parseSort(String sortSpec,
SolrQueryRequest req)
Returns null if the sortSpec is the standard sort desc.
|
static List<String> |
toString(List<Query> queries,
IndexSchema schema)
Builds a list of String which are stringified versions of a list of Queries
|
static String |
toString(Query query,
IndexSchema schema)
Formats a Query for debugging, using the IndexSchema to make
complex field types readable.
|
static void |
toString(Query query,
IndexSchema schema,
Appendable out,
int flags) |
public static final String OP
public static final String V
public static final String F
public static final String TYPE
public static final String DEFTYPE
public static final String LOCALPARAM_START
public static final char LOCALPARAM_END
public static final String DOCID
public static final String SCORE
public static final String VAL_EXPLICIT
public static Query parseQuery(String qs, IndexSchema schema)
qs
- query expression in standard Lucene syntaxschema
- used for default operator (overridden by params) and passed to the query parser for field format analysis informationpublic static Query parseQuery(String qs, String defaultField, IndexSchema schema)
qs
- query expression in standard Lucene syntaxdefaultField
- default field used for unqualified search terms in the query expressionschema
- used for default operator (overridden by params) and passed to the query parser for field format analysis informationpublic static Query parseQuery(String qs, String defaultField, SolrParams params, IndexSchema schema)
qs
- query expression in standard Lucene syntaxdefaultField
- default field used for unqualified search terms in the query expressionparams
- used to determine the default operator, overriding the schema specified operatorschema
- used for default operator (overridden by params) and passed to the query parser for field format analysis informationpublic static SolrParams getLocalParams(String txt, SolrParams params) throws ParseException
ParseException
public static Sort parseSort(String sortSpec, SolrQueryRequest req)
The form of the sort specification string currently parsed is:
> SortSpec ::= SingleSort [, SingleSort]* SingleSort ::=Examples:SortDirection SortDirection ::= top | desc | bottom | asc
score desc #normal sort by score (will return null) weight bottom #sort by weight ascending weight desc #sort by weight descending height desc,weight desc #sort by height descending, and use weight descending to break any ties height desc,weight asc #sort by height descending, using weight ascending as a tiebreaker
public static void toString(Query query, IndexSchema schema, Appendable out, int flags) throws IOException
IOException
toString(Query,IndexSchema)
public static String toString(Query query, IndexSchema schema)
The benefit of using this method instead of calling
Query.toString
directly is that it knows about the data
types of each field, so any field which is encoded in a particularly
complex way is still readable. The downside is that it only knows
about built in Query types, and will not be able to format custom
Query classes.
public static List<String> toString(List<Query> queries, IndexSchema schema)
public static FunctionQuery parseFunction(String func, IndexSchema schema) throws ParseException
Syntax Examples....
// Numeric fields default to correct type // (ie: IntFieldSource or FloatFieldSource) // Others use explicit ord(...) to generate numeric field value myfield // OrdFieldSource ord(myfield) // ReverseOrdFieldSource rord(myfield) // LinearFloatFunction on numeric field value linear(myfield,1,2) // MaxFloatFunction of LinearFloatFunction on numeric field value or constant max(linear(myfield,1,2),100) // ReciprocalFloatFunction on numeric field value recip(myfield,1,2,3) // ReciprocalFloatFunction on ReverseOrdFieldSource recip(rord(myfield),1,2,3) // ReciprocalFloatFunction on LinearFloatFunction on ReverseOrdFieldSource recip(linear(rord(myfield),1,2),3,4,5)
ParseException