org.apache.solr.search
Class QParser

java.lang.Object
  extended by org.apache.solr.search.QParser
Direct Known Subclasses:
DisMaxQParser, FunctionQParser

public abstract class QParser
extends Object

Note: This API is experimental and may change in non backward-compatible ways in the future

Version:
$Id: QParser.java 777656 2009-05-22 18:58:38Z shalin $

Field Summary
protected  SolrParams localParams
           
protected  SolrParams params
           
protected  String qstr
           
protected  Query query
           
protected  int recurseCount
           
protected  SolrQueryRequest req
           
 
Constructor Summary
QParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req)
           
 
Method Summary
 void addDebugInfo(NamedList<Object> debugInfo)
           
 String[] getDefaultHighlightFields()
           
 Query getHighlightQuery()
           
 SolrParams getLocalParams()
           
protected  String getParam(String name)
          check both local and global params
 SolrParams getParams()
           
static QParser getParser(String qstr, String defaultType, SolrQueryRequest req)
          Create a QParser to parse qstr, assuming that the default query type is defaultType.
 Query getQuery()
          Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result.
 SolrQueryRequest getReq()
           
 SortSpec getSort(boolean useGlobalParams)
           
 String getString()
           
abstract  Query parse()
          Create and return the Query object represented by qstr
 void setLocalParams(SolrParams localParams)
           
 void setParams(SolrParams params)
           
 void setReq(SolrQueryRequest req)
           
 void setString(String s)
           
 QParser subQuery(String q, String defaultType)
          Create a new QParser for parsing an embedded sub-query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

qstr

protected String qstr

params

protected SolrParams params

localParams

protected SolrParams localParams

req

protected SolrQueryRequest req

recurseCount

protected int recurseCount

query

protected Query query
Constructor Detail

QParser

public QParser(String qstr,
               SolrParams localParams,
               SolrParams params,
               SolrQueryRequest req)
Method Detail

parse

public abstract Query parse()
                     throws ParseException
Create and return the Query object represented by qstr

Throws:
ParseException
See Also:
getQuery()

getLocalParams

public SolrParams getLocalParams()

setLocalParams

public void setLocalParams(SolrParams localParams)

getParams

public SolrParams getParams()

setParams

public void setParams(SolrParams params)

getReq

public SolrQueryRequest getReq()

setReq

public void setReq(SolrQueryRequest req)

getString

public String getString()

setString

public void setString(String s)

getQuery

public Query getQuery()
               throws ParseException
Returns the resulting query from this QParser, calling parse() only the first time and caching the Query result.

Throws:
ParseException

getParam

protected String getParam(String name)
check both local and global params


subQuery

public QParser subQuery(String q,
                        String defaultType)
                 throws ParseException
Create a new QParser for parsing an embedded sub-query

Throws:
ParseException

getSort

public SortSpec getSort(boolean useGlobalParams)
                 throws ParseException
Parameters:
useGlobalParams - look up sort, start, rows in global params if not in local params
Returns:
the sort specification
Throws:
ParseException

getDefaultHighlightFields

public String[] getDefaultHighlightFields()

getHighlightQuery

public Query getHighlightQuery()
                        throws ParseException
Throws:
ParseException

addDebugInfo

public void addDebugInfo(NamedList<Object> debugInfo)

getParser

public static QParser getParser(String qstr,
                                String defaultType,
                                SolrQueryRequest req)
                         throws ParseException
Create a QParser to parse qstr, assuming that the default query type is defaultType. The query type may be overridden by local parameters in the query string itself. For example if defaultType="dismax" and qstr=foo, then the dismax query parser will be used to parse and construct the query object. However if qstr={!prefix f=myfield}foo then the prefix query parser will be used.

Throws:
ParseException


Copyright © 2010 Apache Software Foundation. All Rights Reserved.