org.apache.solr.search
Class SolrQueryParser

java.lang.Object
  extended by org.apache.lucene.queryParser.QueryParser
      extended by org.apache.solr.search.SolrQueryParser
All Implemented Interfaces:
QueryParserConstants
Direct Known Subclasses:
SolrPluginUtils.DisjunctionMaxQueryParser

public class SolrQueryParser
extends QueryParser

A variation on the Lucene QueryParser which knows about the field types and query time analyzers configured in Solr's schema.xml.

This class also deviates from the Lucene QueryParser by using ConstantScore versions of RangeQuery and PrefixQuery to prevent TooManyClauses exceptions.

If the magic field name "_val_" is used in a term or phrase query, the value is parsed as a function.

Author:
yonik
See Also:
QueryParsing.parseFunction(java.lang.String, org.apache.solr.schema.IndexSchema), ConstantScoreRangeQuery, ConstantScorePrefixQuery

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.queryParser.QueryParser
QueryParser.Operator
 
Field Summary
protected  IndexSchema schema
           
 
Fields inherited from class org.apache.lucene.queryParser.QueryParser
AND_OPERATOR, jj_nt, lookingAhead, OR_OPERATOR, 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, STAR, TERM, tokenImage, WILDTERM
 
Constructor Summary
SolrQueryParser(IndexSchema schema, String defaultField)
          Constructs a SolrQueryParser using the schema to understand the formats and datatypes of each field.
 
Method Summary
protected  Query getFieldQuery(String field, String queryText)
           
protected  Query getPrefixQuery(String field, String termStr)
           
protected  Query getRangeQuery(String field, String part1, String part2, boolean inclusive)
           
 
Methods inherited from class org.apache.lucene.queryParser.QueryParser
addClause, Clause, Conjunction, disable_tracing, enable_tracing, escape, generateParseException, getAllowLeadingWildcard, getAnalyzer, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getFuzzyQuery, getLocale, getLowercaseExpandedTerms, getNextToken, getPhraseSlop, getToken, getUseOldRangeQuery, getWildcardQuery, main, Modifiers, parse, Query, ReInit, ReInit, setAllowLeadingWildcard, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setPhraseSlop, setUseOldRangeQuery, Term, TopLevelQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schema

protected final IndexSchema schema
Constructor Detail

SolrQueryParser

public SolrQueryParser(IndexSchema schema,
                       String defaultField)
Constructs a SolrQueryParser using the schema to understand the formats and datatypes of each field. Only the defaultSearchField will be used from the IndexSchema (unless overridden), <solrQueryParser> will not be used.

Parameters:
schema - Used for default search field name if defaultField is null and field information is used for analysis
defaultField - default field used for unspecified search terms. if null, the schema default field is used
See Also:
IndexSchema.getSolrQueryParser(String defaultField)
Method Detail

getFieldQuery

protected Query getFieldQuery(String field,
                              String queryText)
                       throws ParseException
Overrides:
getFieldQuery in class QueryParser
Throws:
ParseException

getRangeQuery

protected Query getRangeQuery(String field,
                              String part1,
                              String part2,
                              boolean inclusive)
                       throws ParseException
Overrides:
getRangeQuery in class QueryParser
Throws:
ParseException

getPrefixQuery

protected Query getPrefixQuery(String field,
                               String termStr)
                        throws ParseException
Overrides:
getPrefixQuery in class QueryParser
Throws:
ParseException


Copyright © 2006 - 2009 The Apache Software Foundation