Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.queryParser
Class MultiFieldQueryParser

    java.lang.Object
      org.apache.lucene.queryParser.QueryParser
          org.apache.lucene.queryParser.MultiFieldQueryParser

All Implemented Interfaces:
  QueryParserConstants

public class MultiFieldQueryParser
extends QueryParser

A QueryParser which constructs queries to search multiple fields.

Version:
  $Revision: 1.4 $
Author:
  Kelvin Tan

Field Summary
`static int` | `NORMAL_FIELD`
`static int` | `PROHIBITED_FIELD`
`static int` | `REQUIRED_FIELD`

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
`_ESCAPED_CHAR, _NUM_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, RangeEx, RANGEEX_END, RANGEEX_GOOP, RANGEEX_QUOTED, RANGEEX_START, RANGEEX_TO, RangeIn, RANGEIN_END, RANGEIN_GOOP, RANGEIN_QUOTED, RANGEIN_START, RANGEIN_TO, RPAREN, TERM, tokenImage, WILDTERM`

Constructor Summary
`MultiFieldQueryParser(CharStream stream)`
`MultiFieldQueryParser(QueryParserTokenManager tm)`
`MultiFieldQueryParser(String f, Analyzer a)`

Method Summary
`static Query` | `parse(String query, 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.

Methods inherited from class org.apache.lucene.queryParser.QueryParser
`addClause, Clause, Conjunction, 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, Modifiers, parse, parse, Query, ReInit, ReInit, setFuzzyMinSim, setLocale, setLowercaseWildcardTerms, setOperator, setPhraseSlop, Term`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NORMAL_FIELD

    public static final int NORMAL_FIELD

See Also:
  Constant Field Values

### REQUIRED_FIELD

    public static final int REQUIRED_FIELD

See Also:
  Constant Field Values

### PROHIBITED_FIELD

    public static final int PROHIBITED_FIELD

See Also:
  Constant Field Values

Constructor Detail

### MultiFieldQueryParser

    public MultiFieldQueryParser(QueryParserTokenManager tm)

### MultiFieldQueryParser

    public MultiFieldQueryParser(CharStream stream)

### MultiFieldQueryParser

    public MultiFieldQueryParser(String f,
                                 Analyzer a)

Method Detail

### parse

    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 parse
    `fields` - Fields to search on
    `analyzer` - Analyzer to use
  Throws:
    `ParseException` - if query parsing fails
    `TokenMgrError` - if query parsing fails

### parse

    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:

       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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.