public abstract class VespaBackEndSearcher extends PingableSearcher
Modifier and Type | Class and Description |
---|---|
private static class |
VespaBackEndSearcher.FillHitResult |
protected static class |
VespaBackEndSearcher.FillHitsResult |
Modifier and Type | Field and Description |
---|---|
protected CacheControl |
cacheControl
Cache wrapper
|
private String |
defaultDocsumClass
Default docsum class.
|
private DocumentDatabase |
defaultDocumentDb |
private Map<String,DocumentDatabase> |
documentDbs
The set of all document databases available in the backend handled by this searcher
|
private String |
name
The name of this source
|
protected static com.yahoo.processing.request.CompoundName |
PACKET_COMPRESSION_LIMIT |
protected static com.yahoo.processing.request.CompoundName |
PACKET_COMPRESSION_TYPE |
protected static com.yahoo.processing.request.CompoundName |
TRACE_DISABLE |
Constructor and Description |
---|
VespaBackEndSearcher() |
Modifier and Type | Method and Description |
---|---|
private boolean |
addCachedHits(Result result,
PacketWrapper packetWrapper,
String summaryClass,
List<DocumentInfo> documents) |
protected void |
addMetaInfo(Query query,
QueryPacketData queryPacketData,
QueryResultPacket resultPacket,
Result result,
boolean fromCache) |
(package private) boolean |
addUnfilledHits(Result result,
List<DocumentInfo> documents,
boolean fromCache,
QueryPacketData queryPacketData,
CacheKey cacheKey,
Optional<Integer> channelDistributionKey)
Creates unfilled hits from a List of DocumentInfo instances.
|
private Result |
cacheLookupFirstPhase(CacheKey key,
QueryPacketData queryPacketData,
Query query,
int offset,
int hits,
String summaryClass) |
protected PacketWrapper |
cacheLookupTwoPhase(CacheKey cacheKey,
Result result,
String summaryClass) |
private String |
decodeSummary(String summaryClass,
FastHit hit,
byte[] docsumdata) |
private String |
decodeSummary(String summaryClass,
FastHit hit,
byte[] docsumdata,
DocsumDefinitionSet docsumSet) |
protected abstract void |
doPartialFill(Result result,
String summaryClass) |
protected abstract Result |
doSearch2(Query query,
QueryPacket queryPacket,
CacheKey cacheKey,
Execution execution)
Searches a search cluster
This is an endpoint - searchers will never propagate the search to any nested searcher.
|
protected static void |
ensureInstanceOf(Class<? extends BasicPacket> type,
BasicPacket packet,
String name)
Throws an IOException if the packet is not of the expected type
|
private void |
extractDocumentInfo(FastHit hit,
DocumentInfo document) |
void |
fill(Result result,
String summaryClass,
Execution execution)
Fill hit properties with data using the given summary class.
|
private VespaBackEndSearcher.FillHitResult |
fillHit(FastHit hit,
DocsumPacket packet,
String summaryClass) |
protected VespaBackEndSearcher.FillHitsResult |
fillHits(Result result,
Packet[] packets,
String summaryClass)
Fills the hits.
|
CacheControl |
getCacheControl()
Returns the packet cache controller of this
|
private Result |
getCached(CacheKey cacheKey,
QueryPacketData queryPacketData,
Query query)
Returns a cached result, or null if no result was cached for this key
|
protected String |
getDefaultDocsumClass() |
protected DocsumDefinitionSet |
getDocsumDefinitionSet(Query query) |
protected DocumentDatabase |
getDocumentDatabase(Query query) |
protected String |
getName() |
static VespaBackEndSearcher |
getSearcher(String s) |
protected Iterator<Hit> |
hitIterator(Result result)
Returns an iterator which returns all hits below this result
|
void |
init(SummaryParameters docSumParams,
ClusterParams clusterParams,
CacheParams cacheParams,
DocumentdbInfoConfig documentdbInfoConfig) |
protected boolean |
isLoggingFine() |
private void |
mergeErrorsInto(Result destination,
Result source) |
private List<Result> |
partitionHits(Result result,
String summaryClass) |
private void |
resolveDocumentDatabase(Query query) |
Result |
search(Query query,
Execution execution)
Override this to implement your searcher.
|
private void |
setDefaultDocsumClass(String docsumClass)
Sets default document summary class.
|
protected boolean |
summaryNeedsQuery(Query query)
Returns whether we need to send the query when fetching summaries.
|
(package private) static void |
traceQuery(String sourceName,
String type,
Query query,
int offset,
int hits,
int level,
Optional<String> quotedSummaryClass) |
protected void |
transformQuery(Query query) |
ping
ensureFilled, getLogger, process, toString
getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
protected static final com.yahoo.processing.request.CompoundName PACKET_COMPRESSION_LIMIT
protected static final com.yahoo.processing.request.CompoundName PACKET_COMPRESSION_TYPE
protected static final com.yahoo.processing.request.CompoundName TRACE_DISABLE
private Map<String,DocumentDatabase> documentDbs
private DocumentDatabase defaultDocumentDb
private String defaultDocsumClass
private String name
protected CacheControl cacheControl
protected Iterator<Hit> hitIterator(Result result)
protected final String getName()
protected final String getDefaultDocsumClass()
private void setDefaultDocsumClass(String docsumClass)
public final CacheControl getCacheControl()
protected abstract Result doSearch2(Query query, QueryPacket queryPacket, CacheKey cacheKey, Execution execution)
query
- the query to searchqueryPacket
- the serialized query representation to pass to the search clustercacheKey
- the cache key created from the query packet, or null if caching is not usedexecution
- the query execution contextprotected boolean summaryNeedsQuery(Query query)
private Result cacheLookupFirstPhase(CacheKey key, QueryPacketData queryPacketData, Query query, int offset, int hits, String summaryClass)
protected DocumentDatabase getDocumentDatabase(Query query)
private void resolveDocumentDatabase(Query query)
public final void init(SummaryParameters docSumParams, ClusterParams clusterParams, CacheParams cacheParams, DocumentdbInfoConfig documentdbInfoConfig)
protected void transformQuery(Query query)
public Result search(Query query, Execution execution)
Searcher
Searcher implementation subclasses will, depending on their type of logic, do one of the following:
Hits come in two kinds - concrete hits are actual content of the kind requested by the user, meta hits are hits which provides information about the collection of hits, on the query, the service and so on.
The query specifies a window into a larger result list that must be returned from the searcher through hits and offset; Searchers which returns list of hits in the top level in the result must return at least hits number of hits (or if impossible; all that are available), starting at the given offset. In addition, searchers are allowed to return any number of meta hits (although this number is expected to be low). For hits contained in nested hit groups, the concept of a window defined by hits and offset is not well defined and does not apply.
Error handling in searchers:
private Result getCached(CacheKey cacheKey, QueryPacketData queryPacketData, Query query)
cacheKey
- the cache key created from the query packetqueryPacketData
- a serialization of the query, to avoid having to recompute this, or null if not availablequery
- the query, used for tracing, lookup of result window and result creationpublic void fill(Result result, String summaryClass, Execution execution)
Searcher
This needs to be overridden by federating searchers to contact search sources again by propagating the fill call down through the search chain, and by source searchers which talks to fill capable backends to request the data to be filled. Other searchers do not need to override this.
static void traceQuery(String sourceName, String type, Query query, int offset, int hits, int level, Optional<String> quotedSummaryClass)
protected void addMetaInfo(Query query, QueryPacketData queryPacketData, QueryResultPacket resultPacket, Result result, boolean fromCache)
private VespaBackEndSearcher.FillHitResult fillHit(FastHit hit, DocsumPacket packet, String summaryClass)
protected VespaBackEndSearcher.FillHitsResult fillHits(Result result, Packet[] packets, String summaryClass) throws IOException
IOException
protected static void ensureInstanceOf(Class<? extends BasicPacket> type, BasicPacket packet, String name) throws IOException
IOException
private boolean addCachedHits(Result result, PacketWrapper packetWrapper, String summaryClass, List<DocumentInfo> documents)
private void extractDocumentInfo(FastHit hit, DocumentInfo document)
protected PacketWrapper cacheLookupTwoPhase(CacheKey cacheKey, Result result, String summaryClass)
protected DocsumDefinitionSet getDocsumDefinitionSet(Query query)
private String decodeSummary(String summaryClass, FastHit hit, byte[] docsumdata, DocsumDefinitionSet docsumSet)
boolean addUnfilledHits(Result result, List<DocumentInfo> documents, boolean fromCache, QueryPacketData queryPacketData, CacheKey cacheKey, Optional<Integer> channelDistributionKey)
queryPacketData
- binary data from first phase of search, or nullcacheKey
- the key this hit should match in the packet cache, or nullchannelDistributionKey
- distribution key of the node producing these hits.
Only set if produced directly by a search node, not dispatch
(in which case it is not set in the received packets.)public static VespaBackEndSearcher getSearcher(String s)
protected boolean isLoggingFine()
Copyright © 2018. All rights reserved.