Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.lucene.queryParser.QueryParser
org.apache.lucene.queryParser.MultiFieldQueryParser
public class MultiFieldQueryParser
extends QueryParser
Field Summary | |
static int | |
static int | |
static int |
Fields inherited from class org.apache.lucene.queryParser.QueryParser | |
DEFAULT_OPERATOR_AND , DEFAULT_OPERATOR_OR , jj_nt , lookingAhead , token , token_source |
Fields inherited from interface org.apache.lucene.queryParser.QueryParserConstants | |
AND , Boost , CARAT , COLON , DEFAULT , EOF , FUZZY_SLOP , LPAREN , MINUS , NOT , NUMBER , OR , PLUS , PREFIXTERM , QUOTED , RANGEEX_END , RANGEEX_GOOP , RANGEEX_QUOTED , RANGEEX_START , RANGEEX_TO , RANGEIN_END , RANGEIN_GOOP , RANGEIN_QUOTED , RANGEIN_START , RANGEIN_TO , RPAREN , RangeEx , RangeIn , TERM , WILDTERM , _ESCAPED_CHAR , _NUM_CHAR , _TERM_CHAR , _TERM_START_CHAR , _WHITESPACE , tokenImage |
Constructor Summary | |
| |
| |
Methods inherited from class org.apache.lucene.queryParser.QueryParser | |
Clause , Conjunction , Modifiers , Query , ReInit , ReInit , Term , addClause , disable_tracing , enable_tracing , escape , generateParseException , getAnalyzer , getBooleanQuery , getField , getFieldQuery , getFieldQuery , getFieldQuery , getFieldQuery , getFuzzyMinSim , getFuzzyQuery , getFuzzyQuery , getLocale , getLowercaseWildcardTerms , getNextToken , getOperator , getPhraseSlop , getPrefixQuery , getRangeQuery , getRangeQuery , getToken , getWildcardQuery , main , parse , parse , setFuzzyMinSim , setLocale , setLowercaseWildcardTerms , setOperator , setPhraseSlop |
public static final int NORMAL_FIELD
- Field Value:
- 0
public static final int PROHIBITED_FIELD
- Field Value:
- 2
public static final int REQUIRED_FIELD
- Field Value:
- 1
public static Query parse(String query, String[] fields, int[] flags, Analyzer analyzer) throws ParseException
Parses a query, searching on the fields specified. Use this if you need to specify certain fields as required, and others as prohibited.Usage:The code above would construct a query:String[] fields = {"filename", "contents", "description"}; int[] flags = {MultiFieldQueryParser.NORMAL FIELD, MultiFieldQueryParser.REQUIRED FIELD, MultiFieldQueryParser.PROHIBITED FIELD,}; parse(query, fields, flags, analyzer);
(filename:query) +(contents:query) -(description:query)
- Parameters:
query
- Query string to parsefields
- Fields to search onflags
- Flags describing the fieldsanalyzer
- Analyzer to use
- Throws:
ParseException
- if query parsing fails
public static Query parse(String query, String[] fields, Analyzer analyzer) throws ParseException
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 parsefields
- Fields to search onanalyzer
- Analyzer to use
- Throws:
ParseException
- if query parsing fails