|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.queryParser.standard.QueryParserUtil
public final class QueryParserUtil
This class defines utility methods to (help) parse query strings into
Query
objects.
Constructor Summary | |
---|---|
QueryParserUtil()
|
Method Summary | |
---|---|
static String |
escape(String s)
Returns a String where those characters that TextParser expects to be escaped are escaped by a preceding \ . |
static Query |
parse(String[] queries,
String[] fields,
Analyzer analyzer)
Parses a query which searches on the fields specified. |
static Query |
parse(String[] queries,
String[] fields,
BooleanClause.Occur[] flags,
Analyzer analyzer)
Parses a query, searching on the fields specified. |
static Query |
parse(String query,
String[] fields,
BooleanClause.Occur[] flags,
Analyzer analyzer)
Parses a query, searching on the fields specified. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QueryParserUtil()
Method Detail |
---|
public static Query parse(String[] queries, String[] fields, Analyzer analyzer) throws QueryNodeException
If x fields are specified, this effectively constructs:
<code> (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx) </code>
queries
- Queries strings to parsefields
- Fields to search onanalyzer
- Analyzer to use
IllegalArgumentException
- if the length of the queries array differs from the length of the
fields array
QueryNodeException
public static Query parse(String query, String[] fields, BooleanClause.Occur[] flags, Analyzer analyzer) throws QueryNodeException
Usage: <code> String[] fields = {"filename", "contents", "description"}; BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD, BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT}; MultiFieldQueryParser.parse("query", fields, flags, analyzer); </code>
The code above would construct a query:
<code> (filename:query) +(contents:query) -(description:query) </code>
query
- Query string to parsefields
- Fields to search onflags
- Flags describing the fieldsanalyzer
- Analyzer to use
IllegalArgumentException
- if the length of the fields array differs from the length of the
flags array
QueryNodeException
public static Query parse(String[] queries, String[] fields, BooleanClause.Occur[] flags, Analyzer analyzer) throws QueryNodeException
Usage: <code> String[] query = {"query1", "query2", "query3"}; String[] fields = {"filename", "contents", "description"}; BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD, BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT}; MultiFieldQueryParser.parse(query, fields, flags, analyzer); </code>
The code above would construct a query:
<code> (filename:query1) +(contents:query2) -(description:query3) </code>
queries
- Queries string to parsefields
- Fields to search onflags
- Flags describing the fieldsanalyzer
- Analyzer to use
IllegalArgumentException
- if the length of the queries, fields, and flags array differ
QueryNodeException
public static String escape(String s)
\
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |