Package org.apache.solr.search
Class ExtendedDismaxQParser
- java.lang.Object
- 
- org.apache.solr.search.QParser
- 
- org.apache.solr.search.ExtendedDismaxQParser
 
 
- 
 public class ExtendedDismaxQParser extends QParser Query parser that generates DisjunctionMaxQueries based on user configuration. See the Reference Guide page
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classExtendedDismaxQParser.Clausestatic classExtendedDismaxQParser.ExtendedDismaxConfigurationSimple container for configuration information used when parsing queriesstatic classExtendedDismaxQParser.ExtendedSolrQueryParserA subclass of SolrQueryParser that supports aliasing fields for constructing DisjunctionMaxQueries.
 - 
Field Summary- 
Fields inherited from class org.apache.solr.search.QParserFLAG_FILTER, flags, localParams, localParamsEnd, params, qstr, query, recurseCount, req, stringIncludingLocalParams, valFollowedParams
 
- 
 - 
Constructor SummaryConstructors Constructor Description ExtendedDismaxQParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDebugInfo(org.apache.solr.common.util.NamedList<Object> debugInfo)protected voidaddPhraseFieldQueries(org.apache.lucene.search.BooleanQuery.Builder query, List<ExtendedDismaxQParser.Clause> clauses, ExtendedDismaxQParser.ExtendedDismaxConfiguration config)Adds shingled phrase queries to all the fields specified in the pf, pf2 anf pf3 parametersprotected voidaddShingledPhraseQueries(org.apache.lucene.search.BooleanQuery.Builder mainQuery, List<ExtendedDismaxQParser.Clause> clauses, Collection<FieldParams> fields, int shingleSize, float tiebreaker, int slop)Modifies the main query by adding a new optional Query consisting of shingled phrase queries across the specified clauses using the specified field => boost mappings.protected ExtendedDismaxQParser.ExtendedDismaxConfigurationcreateConfiguration(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req)Creates an instance of ExtendedDismaxConfiguration.protected ExtendedDismaxQParser.ExtendedSolrQueryParsercreateEdismaxQueryParser(QParser qParser, String field)Creates an instance of ExtendedSolrQueryParser, the query parser that's going to be used to parse the query.protected List<org.apache.lucene.search.Query>getBoostFunctions()Parses all function queriesprotected List<org.apache.lucene.search.Query>getBoostQueries()Parses all boost queriesString[]getDefaultHighlightFields()StringgetFieldName(String s, int pos, int end)returns a field name or legal field alias from the current position of the stringorg.apache.lucene.search.QuerygetHighlightQuery()protected List<org.apache.lucene.queries.function.ValueSource>getMultiplicativeBoosts()Parses all multiplicative boostsorg.apache.lucene.search.Queryparse()Create and return theQueryobject represented byqstr.protected org.apache.lucene.search.QueryparseEscapedQuery(ExtendedDismaxQParser.ExtendedSolrQueryParser up, String escapedUserQuery, ExtendedDismaxQParser.ExtendedDismaxConfiguration config)Parses an escaped version of the user's query.protected org.apache.lucene.search.QueryparseOriginalQuery(ExtendedDismaxQParser.ExtendedSolrQueryParser up, String mainUserQuery, List<ExtendedDismaxQParser.Clause> clauses, ExtendedDismaxQParser.ExtendedDismaxConfiguration config)Parses the user's original query.protected StringrebuildUserQuery(List<ExtendedDismaxQParser.Clause> clauses, boolean lowercaseOperators)Generates a query string from the raw clauses, uppercasing 'and' and 'or' as needed.protected booleanshouldRemoveStopFilter(ExtendedDismaxQParser.ExtendedDismaxConfiguration config, org.apache.lucene.search.Query query)Determines if query should be re-parsed removing the stop filter.static List<String>split(String s, boolean ignoreQuote)List<ExtendedDismaxQParser.Clause>splitIntoClauses(String s, boolean ignoreQuote)protected voidvalidateQueryFields(ExtendedDismaxQParser.ExtendedSolrQueryParser up)Validate query field names.- 
Methods inherited from class org.apache.solr.search.QParsergetFlags, getLocalParams, getParam, getParams, getParser, getParser, getParser, getQuery, getReq, getSortSpec, getString, isFilter, setFlags, setIsFilter, setLocalParams, setParams, setReq, setString, subQuery
 
- 
 
- 
- 
- 
Constructor Detail- 
ExtendedDismaxQParserpublic ExtendedDismaxQParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req) 
 
- 
 - 
Method Detail- 
parsepublic org.apache.lucene.search.Query parse() throws SyntaxErrorDescription copied from class:QParserCreate and return theQueryobject represented byqstr. Null MAY be returned to signify there was no input (e.g. no query string) to parse.- Specified by:
- parsein class- QParser
- Throws:
- SyntaxError
- See Also:
- QParser.getQuery()
 
 - 
validateQueryFieldsprotected void validateQueryFields(ExtendedDismaxQParser.ExtendedSolrQueryParser up) throws SyntaxError Validate query field names. Must be explicitly defined in the schema or match a dynamic field pattern. Checks source field(s) represented by a field alias- Parameters:
- up- parser used
- Throws:
- SyntaxError- for invalid field name
 
 - 
addPhraseFieldQueriesprotected void addPhraseFieldQueries(org.apache.lucene.search.BooleanQuery.Builder query, List<ExtendedDismaxQParser.Clause> clauses, ExtendedDismaxQParser.ExtendedDismaxConfiguration config) throws SyntaxErrorAdds shingled phrase queries to all the fields specified in the pf, pf2 anf pf3 parameters- Throws:
- SyntaxError
 
 - 
createConfigurationprotected ExtendedDismaxQParser.ExtendedDismaxConfiguration createConfiguration(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req) Creates an instance of ExtendedDismaxConfiguration. It will contain all the necessary parameters to parse the query
 - 
createEdismaxQueryParserprotected ExtendedDismaxQParser.ExtendedSolrQueryParser createEdismaxQueryParser(QParser qParser, String field) Creates an instance of ExtendedSolrQueryParser, the query parser that's going to be used to parse the query.
 - 
parseEscapedQueryprotected org.apache.lucene.search.Query parseEscapedQuery(ExtendedDismaxQParser.ExtendedSolrQueryParser up, String escapedUserQuery, ExtendedDismaxQParser.ExtendedDismaxConfiguration config) throws SyntaxError Parses an escaped version of the user's query. This method is called in the event that the original query encounters exceptions during parsing.- Parameters:
- up- parser used
- escapedUserQuery- query that is parsed, should already be escaped so that no trivial parse errors are encountered
- config- Configuration options for this parse request
- Returns:
- the resulting query (flattened if needed) with "min should match" rules applied as specified in the config.
- Throws:
- SyntaxError
- See Also:
- parseOriginalQuery(org.apache.solr.search.ExtendedDismaxQParser.ExtendedSolrQueryParser, java.lang.String, java.util.List<org.apache.solr.search.ExtendedDismaxQParser.Clause>, org.apache.solr.search.ExtendedDismaxQParser.ExtendedDismaxConfiguration),- SolrPluginUtils.flattenBooleanQuery(org.apache.lucene.search.BooleanQuery.Builder, org.apache.lucene.search.BooleanQuery)
 
 - 
parseOriginalQueryprotected org.apache.lucene.search.Query parseOriginalQuery(ExtendedDismaxQParser.ExtendedSolrQueryParser up, String mainUserQuery, List<ExtendedDismaxQParser.Clause> clauses, ExtendedDismaxQParser.ExtendedDismaxConfiguration config) Parses the user's original query. This method attempts to cleanly parse the specified query string using the specified parser, any Exceptions are ignored resulting in null being returned.- Parameters:
- up- parser used
- mainUserQuery- query string that is parsed
- clauses- used to dictate "min should match" logic
- config- Configuration options for this parse request
- Returns:
- the resulting query with "min should match" rules applied as specified in the config.
- See Also:
- parseEscapedQuery(org.apache.solr.search.ExtendedDismaxQParser.ExtendedSolrQueryParser, java.lang.String, org.apache.solr.search.ExtendedDismaxQParser.ExtendedDismaxConfiguration)
 
 - 
shouldRemoveStopFilterprotected boolean shouldRemoveStopFilter(ExtendedDismaxQParser.ExtendedDismaxConfiguration config, org.apache.lucene.search.Query query) Determines if query should be re-parsed removing the stop filter.- Returns:
- true if there are stopwords configured and the parsed query was empty false in any other case.
 
 - 
rebuildUserQueryprotected String rebuildUserQuery(List<ExtendedDismaxQParser.Clause> clauses, boolean lowercaseOperators) Generates a query string from the raw clauses, uppercasing 'and' and 'or' as needed.- Parameters:
- clauses- the clauses of the query string to be rebuilt
- lowercaseOperators- if true, lowercase 'and' and 'or' clauses will be recognized as operators and uppercased in the final query string.
- Returns:
- the generated query string.
 
 - 
getMultiplicativeBoostsprotected List<org.apache.lucene.queries.function.ValueSource> getMultiplicativeBoosts() throws SyntaxError Parses all multiplicative boosts- Throws:
- SyntaxError
 
 - 
getBoostFunctionsprotected List<org.apache.lucene.search.Query> getBoostFunctions() throws SyntaxError Parses all function queries- Throws:
- SyntaxError
 
 - 
getBoostQueriesprotected List<org.apache.lucene.search.Query> getBoostQueries() throws SyntaxError Parses all boost queries- Throws:
- SyntaxError
 
 - 
addShingledPhraseQueriesprotected void addShingledPhraseQueries(org.apache.lucene.search.BooleanQuery.Builder mainQuery, List<ExtendedDismaxQParser.Clause> clauses, Collection<FieldParams> fields, int shingleSize, float tiebreaker, int slop) throws SyntaxErrorModifies the main query by adding a new optional Query consisting of shingled phrase queries across the specified clauses using the specified field => boost mappings.- Parameters:
- mainQuery- Where the phrase boosting queries will be added
- clauses- Clauses that will be used to construct the phrases
- fields- Field => boost mappings for the phrase queries
- shingleSize- how big the phrases should be, 0 means a single phrase
- tiebreaker- tie breaker value for the DisjunctionMaxQueries
- Throws:
- SyntaxError
 
 - 
getDefaultHighlightFieldspublic String[] getDefaultHighlightFields() - Overrides:
- getDefaultHighlightFieldsin class- QParser
 
 - 
getHighlightQuerypublic org.apache.lucene.search.Query getHighlightQuery() throws SyntaxError- Overrides:
- getHighlightQueryin class- QParser
- Throws:
- SyntaxError
 
 - 
addDebugInfopublic void addDebugInfo(org.apache.solr.common.util.NamedList<Object> debugInfo) - Overrides:
- addDebugInfoin class- QParser
 
 - 
splitIntoClausespublic List<ExtendedDismaxQParser.Clause> splitIntoClauses(String s, boolean ignoreQuote) 
 - 
getFieldNamepublic String getFieldName(String s, int pos, int end) returns a field name or legal field alias from the current position of the string
 
- 
 
-