Package org.apache.solr.search
Class QueryParsing
- java.lang.Object
-
- org.apache.solr.search.QueryParsing
-
public class QueryParsing extends Object
Collection of static utilities useful for query parsing.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFTYPE
static String
F
static char
LOCALPARAM_END
static String
LOCALPARAM_START
static String
OP
static String
SPLIT_ON_WHITESPACE
static String
TYPE
static String
V
static String
VAL_EXPLICIT
-
Constructor Summary
Constructors Constructor Description QueryParsing()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SolrParams
getLocalParams(String txt, SolrParams params)
"foo" returns null "{!prefix f=myfield}yes" returns type="prefix",f="myfield",v="yes" "{!prefix f=myfield v=$p}" returns type="prefix",f="myfield",v=params.get("p")static int
parseLocalParams(String txt, int start, ModifiableSolrParams target, SolrParams params)
static int
parseLocalParams(String txt, int start, ModifiableSolrParams target, SolrParams params, String startString, char endChar)
static QueryParser.Operator
parseOP(String operator)
Parses default operator string into Operator objectstatic List<String>
toString(List<org.apache.lucene.search.Query> queries, IndexSchema schema)
Builds a list of String which are stringified versions of a list of Queriesstatic String
toString(org.apache.lucene.search.Query query, IndexSchema schema)
Formats a Query for debugging, using the IndexSchema to make complex field types readable.static void
toString(org.apache.lucene.search.Query query, IndexSchema schema, Appendable out, int flags)
-
-
-
Field Detail
-
OP
public static final String OP
- See Also:
- Constant Field Values
-
V
public static final String V
- See Also:
- Constant Field Values
-
F
public static final String F
- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
- See Also:
- Constant Field Values
-
DEFTYPE
public static final String DEFTYPE
- See Also:
- Constant Field Values
-
SPLIT_ON_WHITESPACE
public static final String SPLIT_ON_WHITESPACE
- See Also:
- Constant Field Values
-
LOCALPARAM_START
public static final String LOCALPARAM_START
- See Also:
- Constant Field Values
-
LOCALPARAM_END
public static final char LOCALPARAM_END
- See Also:
- Constant Field Values
-
VAL_EXPLICIT
public static final String VAL_EXPLICIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseLocalParams
public static int parseLocalParams(String txt, int start, ModifiableSolrParams target, SolrParams params) throws SyntaxError
- Parameters:
txt
- Text to parsestart
- Index into text for start of parsingtarget
- Object to inject with parsed settingsparams
- Additional existing parameters- Throws:
SyntaxError
-
parseLocalParams
public static int parseLocalParams(String txt, int start, ModifiableSolrParams target, SolrParams params, String startString, char endChar) throws SyntaxError
- Parameters:
txt
- Text to parsestart
- Index into text for start of parsingtarget
- Object to inject with parsed settingsparams
- Additional existing parametersstartString
- String that indicates the start of a localParams sectionendChar
- Character that indicates the end of a localParams section- Throws:
SyntaxError
-
getLocalParams
public static SolrParams getLocalParams(String txt, SolrParams params) throws SyntaxError
"foo" returns null "{!prefix f=myfield}yes" returns type="prefix",f="myfield",v="yes" "{!prefix f=myfield v=$p}" returns type="prefix",f="myfield",v=params.get("p")- Throws:
SyntaxError
-
toString
public static void toString(org.apache.lucene.search.Query query, IndexSchema schema, Appendable out, int flags) throws IOException
- Throws:
IOException
- See Also:
toString(Query,IndexSchema)
-
toString
public static String toString(org.apache.lucene.search.Query query, IndexSchema schema)
Formats a Query for debugging, using the IndexSchema to make complex field types readable.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.
-
toString
public static List<String> toString(List<org.apache.lucene.search.Query> queries, IndexSchema schema)
Builds a list of String which are stringified versions of a list of Queries
-
parseOP
public static QueryParser.Operator parseOP(String operator)
Parses default operator string into Operator object- Parameters:
operator
- the string from request- Returns:
- Operator.AND if string equals "AND", else return Operator.OR (default)
-
-