|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.solr.search.QueryParsing
public class QueryParsing
Collection of static utilities usefull for query parsing.
Nested Class Summary | |
---|---|
static class |
QueryParsing.SortSpec
SortSpec encapsulates a Lucene Sort and a count of the number of documents to return. |
Field Summary | |
---|---|
static String |
OP
the SolrParam used to override the QueryParser "default operator" |
Constructor Summary | |
---|---|
QueryParsing()
|
Method Summary | |
---|---|
static FunctionQuery |
parseFunction(String func,
IndexSchema schema)
Parse a function, returning a FunctionQuery |
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 QueryParsing.SortSpec |
parseSort(String sortSpec,
IndexSchema schema)
Returns null if the sortSpec string doesn't look like a sort specification, or if the sort specification couldn't be converted into a Lucene Sort (because of a field not being indexed or undefined, etc). |
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String OP
Constructor Detail |
---|
public QueryParsing()
Method Detail |
---|
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 QueryParsing.SortSpec parseSort(String sortSpec, IndexSchema schema)
The form of the sort specification string currently parsed is:
> SortSpec ::= SingleSort [, SingleSort]*Examples:? SingleSort ::= SortDirection SortDirection ::= top | desc | bottom | asc
top 10 #take the top 10 by score desc 10 #take the top 10 by score score desc 10 #take the top 10 by score weight bottom 10 #sort by weight ascending and take the first 10 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 top 20 #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 thta it only knows
about built in Query types, and will not be able to format custom
Query classes.
public static FunctionQuery parseFunction(String func, IndexSchema schema) throws ParseException
Syntax Examples....
// Numeric fields default to correct type // (ie: IntFieldSource or FloatFieldSource) // Others use implicit 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |