public class QueryElevationComponent extends SearchComponent implements SolrCoreAware
Modifier and Type | Class and Description |
---|---|
protected class |
QueryElevationComponent.DefaultElevationProvider
Provides elevations with either:
subset match - all the elevating terms are matched in the search query, in any order.
exact match - the elevating query matches fully (all terms in same order) the search query.
The terms are tokenized with the query analyzer.
|
protected static class |
QueryElevationComponent.ElevatingQuery
Query triggering elevation.
|
protected static class |
QueryElevationComponent.Elevation
Elevation of some documents in search results, with potential exclusion of others.
|
class |
QueryElevationComponent.ElevationBuilder
Builds an
QueryElevationComponent.Elevation . |
protected static interface |
QueryElevationComponent.ElevationProvider
Provides the elevations defined for queries.
|
protected static class |
QueryElevationComponent.InitializationExceptionCause |
protected static class |
QueryElevationComponent.TrieSubsetMatcher<E extends Comparable<? super E>,M>
Matches a potentially large collection of subsets with a trie implementation.
|
SolrInfoBean.Category, SolrInfoBean.Group
Modifier and Type | Field and Description |
---|---|
static String |
BOOSTED
Key to
SolrQueryRequest.getContext() for a Set<BytesRef> of included IDs in configured
order (so-called priority). |
static String |
EXCLUDED
Key to
SolrQueryRequest.getContext() for a Set<BytesRef> of excluded IDs. |
protected boolean |
forceElevation |
protected SolrParams |
initArgs |
protected boolean |
initialized |
protected static QueryElevationComponent.ElevationProvider |
NO_OP_ELEVATION_PROVIDER
QueryElevationComponent.ElevationProvider that returns no elevation. |
protected Analyzer |
queryAnalyzer |
protected SchemaField |
uniqueKeyField |
protected boolean |
useConfiguredElevatedOrder |
metricNames, registry, standard_components
Constructor and Description |
---|
QueryElevationComponent() |
Modifier and Type | Method and Description |
---|---|
String |
analyzeQuery(String query)
Analyzes the provided query string and returns a concatenation of the analyzed tokens.
|
protected void |
analyzeQuery(String query,
Consumer<CharSequence> termsConsumer)
Analyzes the provided query string, tokenizes the terms, and adds them to the provided
Consumer . |
protected QueryElevationComponent.ElevationProvider |
createElevationProvider(Map<QueryElevationComponent.ElevatingQuery,QueryElevationComponent.ElevationBuilder> elevationBuilderMap)
Creates the
QueryElevationComponent.ElevationProvider to set during configuration loading. |
static com.carrotsearch.hppc.IntIntHashMap |
getBoostDocs(SolrIndexSearcher indexSearcher,
Set<BytesRef> boosted,
Map context)
Resolves a set of boosted docs by uniqueKey to a map of docIds mapped to a priority value > 0.
|
String |
getDescription()
Simple one or two line description
|
protected QueryElevationComponent.Elevation |
getElevation(ResponseBuilder rb) |
protected <E extends Exception> |
handleConfigLoadingException(E e,
boolean resourceAccessIssue)
Handles an exception that occurred while loading the configuration resource.
|
protected void |
handleInitializationException(Exception exception,
QueryElevationComponent.InitializationExceptionCause cause)
Handles the exception that occurred while initializing this component.
|
void |
inform(SolrCore core) |
void |
init(NamedList args) |
protected boolean |
isSubsetMatchPolicy(String matchString) |
protected int |
loadElevationConfiguration(SolrCore core)
(Re)Loads elevation configuration.
|
protected QueryElevationComponent.ElevationProvider |
loadElevationProvider(XmlConfigFile config)
Loads the
QueryElevationComponent.ElevationProvider . |
void |
prepare(ResponseBuilder rb)
Prepare the response.
|
void |
process(ResponseBuilder rb)
Process the request for this component
|
distributedProcess, finishStage, getCategory, getMetricNames, getMetricRegistry, getName, handleResponses, modifyRequest, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMetricsSnapshot, registerMetricName
public static final String BOOSTED
SolrQueryRequest.getContext()
for a Set<BytesRef>
of included IDs in configured
order (so-called priority).public static final String EXCLUDED
SolrQueryRequest.getContext()
for a Set<BytesRef>
of excluded IDs.protected SolrParams initArgs
protected Analyzer queryAnalyzer
protected SchemaField uniqueKeyField
protected boolean forceElevation
QueryElevationParams.FORCE_ELEVATION
protected boolean useConfiguredElevatedOrder
protected boolean initialized
protected static final QueryElevationComponent.ElevationProvider NO_OP_ELEVATION_PROVIDER
QueryElevationComponent.ElevationProvider
that returns no elevation.public void init(NamedList args)
init
in interface NamedListInitializedPlugin
init
in class SearchComponent
public void inform(SolrCore core)
inform
in interface SolrCoreAware
protected int loadElevationConfiguration(SolrCore core) throws Exception
core
- The core holding this component.Exception
protected void handleInitializationException(Exception exception, QueryElevationComponent.InitializationExceptionCause cause)
initialized
which becomes false
.protected <E extends Exception> QueryElevationComponent.ElevationProvider handleConfigLoadingException(E e, boolean resourceAccessIssue) throws E extends Exception
e
- The exception caught.resourceAccessIssue
- true
if the exception has been thrown
because the resource could not be accessed (missing or cannot be read)
or the config file is empty; false
if the resource has
been found and accessed but the error occurred while loading the resource
(invalid format, incomplete or corrupted).QueryElevationComponent.ElevationProvider
to use if the exception is absorbed. If null
is returned, the NO_OP_ELEVATION_PROVIDER
is used but not cached in
the QueryElevationComponent.ElevationProvider
cache.E
- If the exception is not absorbed.E extends Exception
protected QueryElevationComponent.ElevationProvider loadElevationProvider(XmlConfigFile config)
QueryElevationComponent.ElevationProvider
.RuntimeException
- If the config does not provide an XML content of the expected format
(either RuntimeException
or SolrException
).protected boolean isSubsetMatchPolicy(String matchString)
public void prepare(ResponseBuilder rb) throws IOException
SearchComponent
SearchComponent.process(org.apache.solr.handler.component.ResponseBuilder)
method.
Called for every incoming request.
The place to do initialization that is request dependent.prepare
in class SearchComponent
rb
- The ResponseBuilder
IOException
- If there is a low-level I/O error.public void process(ResponseBuilder rb) throws IOException
SearchComponent
process
in class SearchComponent
rb
- The ResponseBuilder
IOException
- If there is a low-level I/O error.protected QueryElevationComponent.Elevation getElevation(ResponseBuilder rb)
public static com.carrotsearch.hppc.IntIntHashMap getBoostDocs(SolrIndexSearcher indexSearcher, Set<BytesRef> boosted, Map context) throws IOException
indexSearcher
- the SolrIndexSearcher; requiredboosted
- are the set of uniqueKey values to be boosted in priority order. If null; returns null.context
- the SolrQueryRequest.getContext()
or null if none. We'll cache our results here.IOException
public String getDescription()
SolrInfoBean
getDescription
in interface SolrInfoBean
getDescription
in class SearchComponent
protected QueryElevationComponent.ElevationProvider createElevationProvider(Map<QueryElevationComponent.ElevatingQuery,QueryElevationComponent.ElevationBuilder> elevationBuilderMap)
QueryElevationComponent.ElevationProvider
to set during configuration loading. The same instance will be used later
when elevating results for queries.elevationBuilderMap
- map of all QueryElevationComponent.ElevatingQuery
and their corresponding QueryElevationComponent.ElevationBuilder
.QueryElevationComponent.ElevationProvider
.public String analyzeQuery(String query)
protected void analyzeQuery(String query, Consumer<CharSequence> termsConsumer)
Consumer
.Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.