Package com.yahoo.search
Class Result
java.lang.Object
com.yahoo.component.provider.FreezableClass
com.yahoo.component.provider.ListenableFreezableClass
com.yahoo.processing.Response
com.yahoo.search.Result
- All Implemented Interfaces:
com.yahoo.component.provider.Freezable
,com.yahoo.component.provider.ListenableFreezable
,Cloneable
The Result contains all the data produced by executing a Query: Some very limited global information, and
a single HitGroup containing hits of the result. The HitGroup may contain Hits, which are the individual
result items, as well as further HitGroups, making up a composite structure. This allows the hits of a result
to be hierarchically organized. A Hit is polymorphic and may contain any kind of information deemed
an appropriate partial answer to the Query.
Do not cache this as it holds references to objects that should be garbage collected.
- Author:
- bratseth
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Update cached and filled by iterating through the hits of this resultclone()
Deep clones this result - copies are made of all hits and subgroups of hits, but not of the query referenced by this.com.yahoo.processing.response.DataList<?>
data()
int
Returns the total number of concrete hits contained (directly or in subgroups) in this result.getContext
(boolean create) Returns the context of this result - this is equal to getQuery().getContext(create)getCoverage
(boolean create) Returns coverage informationlong
Returns the estimated total number of deep hits, which includes every object which matches the query.boolean
getHeaders
(boolean create) Returns the set of "envelope" headers to be returned with this result.int
Returns the number of hit objects available in the top level group of this result.Returns the orderer used by the top level group, or null if the default relevancy order is usedgetQuery()
Returns the query which produced this resultlong
Returns the estimated total number of concrete hits which would be returned for this query.hits()
Returns the top level hit group containing all the hits of this resultboolean
isCached()
Returns true only if _all_ hits in this result originates from a cache.boolean
Returns whether all hits in this result have been filled with the properties contained in the given summary class.void
Merges meta information from a result into this.void
mergeWithAfterFill
(Result result) Merges meta information produced when a Hit already contained in this result has been filled using another result as an intermediary.void
setCoverage
(Coverage coverage) void
setDeepHitCount
(long deepHitCount) Sets the estimated total number of deep hits this result is a subset ofvoid
setDeletionBreaksOrdering
(boolean flag) void
void
setHitOrderer
(HitOrderer hitOrderer) Sets the hit orderer to be used for the top level hit group.void
Sets the top level hit group containing all the hits of this resultvoid
Sets a query for this resultvoid
setTotalHitCount
(long totalHitCount) Sets the estimated total number of hits this result is a subset oftoString()
void
Adds a context message to this query containing the entire content of this result, if tracelevel is 5 or more.protected void
traceExtraHitProperties
(StringBuilder hitBuffer, Hit hit) For tracing custom properties of a hit, see trace(String).Methods inherited from class com.yahoo.processing.Response
mergeWith, recursiveFuture
Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass
addFreezeListener, freeze
Methods inherited from class com.yahoo.component.provider.FreezableClass
ensureNotFrozen, isFrozen
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.yahoo.component.provider.Freezable
isFrozen
-
Constructor Details
-
Result
Creates a new Result where the top level hit group has id "toplevel" -
Result
Create an empty result. A source creating a result is required to callsetTotalHitCount(long)
before releasing this result.- Parameters:
query
- the query which produced this resulthits
- the hit container which this will return fromhits()
-
Result
Create a result containing an error
-
-
Method Details
-
mergeWith
Merges meta information from a result into this. This does not merge hits, but the other information associated with a result. It should always be called when adding hits from a result, but there is no constraints on the order of the calls. -
mergeWithAfterFill
Merges meta information produced when a Hit already contained in this result has been filled using another result as an intermediary. @see mergeWith(Result) mergeWith. -
getHitCount
public int getHitCount()Returns the number of hit objects available in the top level group of this result. Note that this number is allowed to be higher than the requested number of hits, because a searcher is allowed to add meta hits as well as the requested number of concrete hits. -
getConcreteHitCount
public int getConcreteHitCount()Returns the total number of concrete hits contained (directly or in subgroups) in this result. This should equal the requested hits count if the query has that many matches.
-
getTotalHitCount
public long getTotalHitCount()Returns the estimated total number of concrete hits which would be returned for this query. -
getDeepHitCount
public long getDeepHitCount()Returns the estimated total number of deep hits, which includes every object which matches the query. This is always at least the same as totalHitCount. A lower value will cause hitCount to be returned. -
setTotalHitCount
public void setTotalHitCount(long totalHitCount) Sets the estimated total number of hits this result is a subset of -
setDeepHitCount
public void setDeepHitCount(long deepHitCount) Sets the estimated total number of deep hits this result is a subset of -
getElapsedTime
-
setElapsedTime
-
isCached
public boolean isCached()Returns true only if _all_ hits in this result originates from a cache. -
isFilled
Returns whether all hits in this result have been filled with the properties contained in the given summary class. Note that this method will also return true if no hits in this result are fillable. -
getQuery
Returns the query which produced this result -
setQuery
Sets a query for this result -
setHitOrderer
Sets the hit orderer to be used for the top level hit group.
- Parameters:
hitOrderer
- the new hit orderer, or null to use default relevancy ordering
-
getHitOrderer
Returns the orderer used by the top level group, or null if the default relevancy order is used -
setDeletionBreaksOrdering
public void setDeletionBreaksOrdering(boolean flag) -
getDeletionBreaksOrdering
public boolean getDeletionBreaksOrdering() -
analyzeHits
public void analyzeHits()Update cached and filled by iterating through the hits of this result -
hits
Returns the top level hit group containing all the hits of this result -
data
public com.yahoo.processing.response.DataList<?> data()- Overrides:
data
in classcom.yahoo.processing.Response
-
setHits
Sets the top level hit group containing all the hits of this result -
clone
Deep clones this result - copies are made of all hits and subgroups of hits, but not of the query referenced by this.- Overrides:
clone
in classcom.yahoo.component.provider.ListenableFreezableClass
-
toString
-
trace
Adds a context message to this query containing the entire content of this result, if tracelevel is 5 or more.- Parameters:
name
- the name of the searcher instance returning this result
-
traceExtraHitProperties
For tracing custom properties of a hit, see trace(String). An example of using this is in com.yahoo.prelude.Result.- Parameters:
hitBuffer
- the render targethit
- the hit to be analyzed
-
getContext
Returns the context of this result - this is equal to getQuery().getContext(create) -
setCoverage
-
getCoverage
Returns coverage information- Parameters:
create
- if true the coverage information of this result is created if missing- Returns:
- the coverage information of this, or null if none and create is false
-
getHeaders
Returns the set of "envelope" headers to be returned with this result. This returns the live map in modifiable form - modify this to change the headers. Or null if none, and it should not be created.Used for HTTP headers when the return protocol is HTTP, e.g
result.getHeaders(true).put("Cache-Control","max-age=120")
- Parameters:
create
- if true, create the header ListMap if it does not exist- Returns:
- returns the ListMap of current headers, or null if no headers are set and
create
is false
-