org.apache.solr.util
Class SolrPluginUtils.DisjunctionMaxQueryParser

java.lang.Object
  extended by org.apache.lucene.queryparser.classic.QueryParserBase
      extended by org.apache.lucene.queryparser.classic.QueryParser
          extended by org.apache.solr.search.SolrQueryParser
              extended by org.apache.solr.util.SolrPluginUtils.DisjunctionMaxQueryParser
All Implemented Interfaces:
QueryParserConstants
Enclosing class:
SolrPluginUtils

public static class SolrPluginUtils.DisjunctionMaxQueryParser
extends SolrQueryParser

A subclass of SolrQueryParser that supports aliasing fields for constructing DisjunctionMaxQueries.


Nested Class Summary
protected static class SolrPluginUtils.DisjunctionMaxQueryParser.Alias
          A simple container for storing alias info
 
Nested classes/interfaces inherited from class org.apache.solr.search.SolrQueryParser
SolrQueryParser.MagicFieldName
 
Nested classes/interfaces inherited from class org.apache.lucene.queryparser.classic.QueryParser
QueryParser.Operator
 
Nested classes/interfaces inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
QueryParserBase.MethodRemovedUseAnother
 
Field Summary
protected  Map<String,SolrPluginUtils.DisjunctionMaxQueryParser.Alias> aliases
          Where we store a map from field name we expect to see in our query string, to Alias object containing the fields to use in our DisjunctionMaxQuery and the tiebreaker to use.
 
Fields inherited from class org.apache.solr.search.SolrQueryParser
defaultField, parser, schema
 
Fields inherited from class org.apache.lucene.queryparser.classic.QueryParser
jj_nt, token, token_source
 
Fields inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
AND_OPERATOR, OR_OPERATOR
 
Fields inherited from interface org.apache.lucene.queryparser.classic.QueryParserConstants
_ESCAPED_CHAR, _NUM_CHAR, _QUOTED_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, BAREOPER, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, Range, RANGE_GOOP, RANGE_QUOTED, RANGE_TO, RANGEEX_END, RANGEEX_START, RANGEIN_END, RANGEIN_START, REGEXPTERM, RPAREN, STAR, TERM, tokenImage, WILDTERM
 
Constructor Summary
SolrPluginUtils.DisjunctionMaxQueryParser(QParser qp, String defaultField)
           
 
Method Summary
 void addAlias(String field, float tiebreaker, Map<String,Float> fieldBoosts)
          Add an alias to this query parser.
protected  Query getFieldQuery(String field, String queryText, boolean quoted)
          Delegates to the super class unless the field has been specified as an alias -- in which case we recurse on each of the aliased fields, and the results are composed into a DisjunctionMaxQuery.
 
Methods inherited from class org.apache.solr.search.SolrQueryParser
analyzeIfMultitermTermText, getPrefixQuery, getRangeQuery, getRegexpQuery, getReversedWildcardFilterFactory, getWildcardQuery
 
Methods inherited from class org.apache.lucene.queryparser.classic.QueryParser
Clause, Conjunction, disable_tracing, enable_tracing, generateParseException, getNextToken, getToken, Modifiers, Query, ReInit, ReInit, Term, TopLevelQuery
 
Methods inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
addClause, analyzeMultitermTerm, escape, getAllowLeadingWildcard, getAnalyzer, getAnalyzeRangeTerms, getAutoGeneratePhraseQueries, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getFuzzyQuery, getLocale, getLowercaseExpandedTerms, getMultiTermRewriteMethod, getPhraseSlop, init, newBooleanClause, newBooleanQuery, newFieldQuery, newFuzzyQuery, newMatchAllDocsQuery, newMultiPhraseQuery, newPhraseQuery, newPrefixQuery, newRangeQuery, newRegexpQuery, newTermQuery, newWildcardQuery, parse, setAllowLeadingWildcard, setAnalyzeRangeTerms, setAutoGeneratePhraseQueries, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aliases

protected Map<String,SolrPluginUtils.DisjunctionMaxQueryParser.Alias> aliases
Where we store a map from field name we expect to see in our query string, to Alias object containing the fields to use in our DisjunctionMaxQuery and the tiebreaker to use.

Constructor Detail

SolrPluginUtils.DisjunctionMaxQueryParser

public SolrPluginUtils.DisjunctionMaxQueryParser(QParser qp,
                                                 String defaultField)
Method Detail

addAlias

public void addAlias(String field,
                     float tiebreaker,
                     Map<String,Float> fieldBoosts)
Add an alias to this query parser.

Parameters:
field - the field name that should trigger alias mapping
fieldBoosts - the mapping from fieldname to boost value that should be used to build up the clauses of the DisjunctionMaxQuery.
tiebreaker - to the tiebreaker to be used in the DisjunctionMaxQuery
See Also:
SolrPluginUtils.parseFieldBoosts(java.lang.String)

getFieldQuery

protected Query getFieldQuery(String field,
                              String queryText,
                              boolean quoted)
                       throws ParseException
Delegates to the super class unless the field has been specified as an alias -- in which case we recurse on each of the aliased fields, and the results are composed into a DisjunctionMaxQuery. (so yes: aliases which point at other aliases should work)

Overrides:
getFieldQuery in class SolrQueryParser
Throws:
ParseException


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