@Deprecated public class MultiFieldQueryParserWrapper extends QueryParserWrapper
QueryParserWrapper.Operator
AND_OPERATOR, OR_OPERATOR
Constructor and Description |
---|
MultiFieldQueryParserWrapper(String[] fields,
org.apache.lucene.analysis.Analyzer analyzer)
Deprecated.
Creates a MultiFieldQueryParser.
|
MultiFieldQueryParserWrapper(String[] fields,
org.apache.lucene.analysis.Analyzer analyzer,
Map<String,Float> boosts)
Deprecated.
Creates a MultiFieldQueryParser.
|
Modifier and Type | Method and Description |
---|---|
static org.apache.lucene.search.Query |
parse(String[] queries,
String[] fields,
org.apache.lucene.analysis.Analyzer analyzer)
Deprecated.
Parses a query which searches on the fields specified.
|
static org.apache.lucene.search.Query |
parse(String[] queries,
String[] fields,
org.apache.lucene.search.BooleanClause.Occur[] flags,
org.apache.lucene.analysis.Analyzer analyzer)
Deprecated.
Parses a query, searching on the fields specified.
|
static org.apache.lucene.search.Query |
parse(String query,
String[] fields,
org.apache.lucene.search.BooleanClause.Occur[] flags,
org.apache.lucene.analysis.Analyzer analyzer)
Deprecated.
Parses a query, searching on the fields specified.
|
escape, generateParseException, getAllowLeadingWildcard, getAnalyzer, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, getFieldQuery, getFieldQuery, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getFuzzyQuery, getLocale, getLowercaseExpandedTerms, getMultiTermRewriteMethod, getPhraseSlop, getPrefixQuery, getQueryConfigHandler, getQueryProcessor, getRangeCollator, getRangeQuery, getUseOldRangeQuery, getWildcardQuery, parse, setAllowLeadingWildcard, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop, setQueryBuilder, setQueryConfig, setQueryProcessor, setRangeCollator, setUseOldRangeQuery
public MultiFieldQueryParserWrapper(String[] fields, org.apache.lucene.analysis.Analyzer analyzer, Map<String,Float> boosts)
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)
When you pass a boost (title=>5 body=>10) you can get
+(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)
In other words, all the query's terms must appear, but it doesn't matter in what fields they appear.
public MultiFieldQueryParserWrapper(String[] fields, org.apache.lucene.analysis.Analyzer analyzer)
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.
public static org.apache.lucene.search.Query parse(String[] queries, String[] fields, org.apache.lucene.analysis.Analyzer analyzer) throws org.apache.lucene.queryParser.ParseException
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 useorg.apache.lucene.queryParser.ParseException
- if query parsing failsIllegalArgumentException
- if the length of the queries array differs from the length of the
fields arraypublic static org.apache.lucene.search.Query parse(String query, String[] fields, org.apache.lucene.search.BooleanClause.Occur[] flags, org.apache.lucene.analysis.Analyzer analyzer) throws org.apache.lucene.queryParser.ParseException
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 useorg.apache.lucene.queryParser.ParseException
- if query parsing failsIllegalArgumentException
- if the length of the fields array differs from the length of the
flags arraypublic static org.apache.lucene.search.Query parse(String[] queries, String[] fields, org.apache.lucene.search.BooleanClause.Occur[] flags, org.apache.lucene.analysis.Analyzer analyzer) throws org.apache.lucene.queryParser.ParseException
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 useorg.apache.lucene.queryParser.ParseException
- if query parsing failsIllegalArgumentException
- if the length of the queries, fields, and flags array differ