org.apache.lucene.queryParser
public class MultiFieldQueryParser extends QueryParser
Version: $Revision: 295117 $
Field Summary | |
---|---|
static int | NORMAL_FIELD |
static int | PROHIBITED_FIELD |
static int | REQUIRED_FIELD |
Constructor Summary | |
---|---|
MultiFieldQueryParser(String[] fields, Analyzer analyzer)
Creates a MultiFieldQueryParser.
| |
MultiFieldQueryParser(QueryParserTokenManager tm) | |
MultiFieldQueryParser(CharStream stream) | |
MultiFieldQueryParser(String f, Analyzer a) |
Method Summary | |
---|---|
protected Query | getFieldQuery(String field, String queryText, int slop) |
protected Query | getFieldQuery(String field, String queryText) |
protected Query | getFieldQuery(String field, Analyzer analyzer, String queryText) |
protected Query | getFuzzyQuery(String field, String termStr) |
protected Query | getFuzzyQuery(String field, String termStr, float minSimilarity) |
protected Query | getPrefixQuery(String field, String termStr) |
protected Query | getRangeQuery(String field, Analyzer analyzer, String part1, String part2, boolean inclusive) |
protected Query | getRangeQuery(String field, String part1, String part2, boolean inclusive) |
protected Query | getWildcardQuery(String field, String termStr) |
static Query | parse(String query, String[] fields, Analyzer analyzer)
Parses a query which searches on the fields specified.
|
static Query | parse(String[] queries, String[] fields, Analyzer analyzer)
Parses a query which searches on the fields specified.
|
static Query | parse(String query, String[] fields, int[] 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.
|
static Query | parse(String[] queries, String[] fields, int[] flags, Analyzer analyzer)
Parses a query, searching on the fields specified. |
static Query | parse(String[] queries, String[] fields, BooleanClause.Occur[] flags, Analyzer analyzer)
Parses a query, searching on the fields specified.
|
Deprecated:
Deprecated:
Deprecated:
It will, when parse(String query)
is called, construct a query like this (assuming the query consists of
two terms and you specify the two fields title
and body
):
(title:term1 body:term1) (title:term2 body:term2)
When setDefaultOperator(AND_OPERATOR) is set, the result will be:
+(title:term1 body:term1) +(title:term2 body:term2)
In other words, all the query's terms must appear, but it doesn't matter in what fields they appear.
Deprecated: use (String[], Analyzer)
instead
Deprecated: use (String[], Analyzer)
instead
Deprecated: use (String[], Analyzer)
instead
Deprecated: use MultiFieldQueryParser
Deprecated: use MultiFieldQueryParser
Deprecated: use MultiFieldQueryParser
Throws: ParseException
Deprecated: use MultiFieldQueryParser instead but note that it returns a different query for queries where all terms are required: its query excepts all terms, no matter in what field they occur whereas the query built by this (deprecated) method expected all terms in all fields at the same time.
Parses a query which searches on the fields specified. If x fields are specified, this effectively constructs:
(field1:query) (field2:query) (field3:query)...(fieldx:query)
Parameters: query Query string to parse fields Fields to search on analyzer Analyzer to use
Throws: ParseException if query parsing fails TokenMgrError if query parsing fails
If x fields are specified, this effectively constructs:
(field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
Parameters: queries Queries strings to parse fields Fields to search on analyzer Analyzer to use
Throws: ParseException if query parsing fails TokenMgrError if query parsing fails IllegalArgumentException if the length of the queries array differs from the length of the fields array
Deprecated: use (String, String[], BooleanClause.Occur[], Analyzer)
instead
Usage:
String[] fields = {"filename", "contents", "description"};
int[] flags = {MultiFieldQueryParser.NORMAL_FIELD,
MultiFieldQueryParser.REQUIRED_FIELD,
MultiFieldQueryParser.PROHIBITED_FIELD,};
parse(query, fields, flags, analyzer);
The code above would construct a query:
(filename:query) +(contents:query) -(description:query)
Parameters: query Query string to parse fields Fields to search on flags Flags describing the fields analyzer Analyzer to use
Throws: ParseException if query parsing fails TokenMgrError if query parsing fails IllegalArgumentException if the length of the fields array differs from the length of the flags array
Usage:
String[] fields = {"filename", "contents", "description"};
BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT};
MultiFieldQueryParser.parse("query", fields, flags, analyzer);
The code above would construct a query:
(filename:query) +(contents:query) -(description:query)
Parameters: query Query string to parse fields Fields to search on flags Flags describing the fields analyzer Analyzer to use
Throws: ParseException if query parsing fails TokenMgrError if query parsing fails IllegalArgumentException if the length of the fields array differs from the length of the flags array
Deprecated: use (String[], String[], BooleanClause.Occur[], Analyzer)
instead
Usage:
String[] fields = { "filename", "contents", "description" };
int[] flags = { MultiFieldQueryParser.NORMAL_FIELD,
MultiFieldQueryParser.REQUIRED_FIELD,
MultiFieldQueryParser.PROHIBITED_FIELD, };
parse(query, fields, flags, analyzer);
The code above would construct a query:
(filename:query1) +(contents:query2) -(description:query3)
Parameters: queries Queries string to parse fields Fields to search on flags Flags describing the fields analyzer Analyzer to use
Throws: ParseException if query parsing fails TokenMgrError if query parsing fails IllegalArgumentException if the length of the queries, fields, and flags array differ
Usage:
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);
The code above would construct a query:
(filename:query1) +(contents:query2) -(description:query3)
Parameters: queries Queries string to parse fields Fields to search on flags Flags describing the fields analyzer Analyzer to use
Throws: ParseException if query parsing fails TokenMgrError if query parsing fails IllegalArgumentException if the length of the queries, fields, and flags array differ