public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrInfoBean, SolrMetricProducer
IndexSearcher
.Modifier and Type | Class and Description |
---|---|
static class |
SolrIndexSearcher.DocsEnumState |
static class |
SolrIndexSearcher.ProcessedFilter |
IndexSearcher.LeafSlice
SolrInfoBean.Category, SolrInfoBean.Group
Modifier and Type | Field and Description |
---|---|
static int |
GET_DOCLIST |
static int |
GET_DOCSET |
static int |
GET_SCORES |
static int |
NO_CHECK_QCACHE |
static AtomicLong |
numCloses |
static AtomicLong |
numOpens |
static String |
STATISTICS_KEY |
static String |
STATS_SOURCE |
static int |
TERMINATE_EARLY |
leafContexts, readerContext
Constructor and Description |
---|
SolrIndexSearcher(SolrCore core,
String path,
IndexSchema schema,
SolrIndexConfig config,
String name,
boolean enableCache,
DirectoryFactory directoryFactory) |
SolrIndexSearcher(SolrCore core,
String path,
IndexSchema schema,
String name,
DirectoryReader r,
boolean closeReader,
boolean enableCache,
boolean reserveDirectory,
DirectoryFactory directoryFactory) |
Modifier and Type | Method and Description |
---|---|
void |
cacheDocSet(Query query,
DocSet optionalAnswer,
boolean mustCache)
Compute and cache the DocSet that matches a query.
|
Object |
cacheInsert(String cacheName,
Object key,
Object val)
insert an entry in a generic cache
|
Object |
cacheLookup(String cacheName,
Object key)
lookup an entry in a generic cache
|
void |
close()
Free's resources associated with this searcher.
|
CollectionStatistics |
collectionStatistics(String field) |
Document |
doc(int docId)
Retrieve the
Document instance corresponding to the document id. |
Document |
doc(int i,
Set<String> fields)
Retrieve the
Document instance corresponding to the document id. |
void |
doc(int docId,
StoredFieldVisitor visitor)
Visit a document's fields using a
StoredFieldVisitor . |
int |
docFreq(Term term) |
Explanation |
explain(Query query,
int doc) |
SolrCache |
getCache(String cacheName)
return the named generic cache
|
SolrInfoBean.Category |
getCategory()
Category of this component
|
SolrCore |
getCore() |
String |
getDescription()
Simple one or two line description
|
SolrDocumentFetcher |
getDocFetcher() |
DocList |
getDocList(Query query,
DocSet filter,
Sort lsort,
int offset,
int len)
Returns documents matching both
query and filter and sorted by sort . |
DocList |
getDocList(Query query,
List<Query> filterList,
Sort lsort,
int offset,
int len,
int flags)
Returns documents matching both
query and the intersection of the filterList , sorted by
sort . |
DocList |
getDocList(Query query,
Query filter,
Sort lsort,
int offset,
int len)
Returns documents matching both
query and filter and sorted by sort . |
DocListAndSet |
getDocListAndSet(Query query,
DocSet filter,
Sort lsort,
int offset,
int len)
Returns documents matching both
query and filter and sorted by sort . |
DocListAndSet |
getDocListAndSet(Query query,
DocSet filter,
Sort lsort,
int offset,
int len,
int flags)
Returns documents matching both
query and filter and sorted by sort . |
DocListAndSet |
getDocListAndSet(Query query,
List<Query> filterList,
Sort lsort,
int offset,
int len)
Returns documents matching both
query and the intersection of filterList , sorted by
sort . |
DocListAndSet |
getDocListAndSet(Query query,
List<Query> filterList,
Sort lsort,
int offset,
int len,
int flags)
Returns documents matching both
query and the intersection of filterList , sorted by
sort . |
DocListAndSet |
getDocListAndSet(Query query,
Query filter,
Sort lsort,
int offset,
int len)
Returns documents matching both
query and filter and sorted by sort . |
DocListAndSet |
getDocListAndSet(Query query,
Query filter,
Sort lsort,
int offset,
int len,
int flags)
Returns documents matching both
query and filter and sorted by sort . |
DocSet |
getDocSet(List<Query> queries)
Returns the set of document ids matching all queries.
|
DocSet |
getDocSet(Query query)
Returns the set of document ids matching a query.
|
DocSet |
getDocSet(Query query,
DocSet filter)
Returns the set of document ids matching both the query and the filter.
|
DocSet |
getDocSet(SolrIndexSearcher.DocsEnumState deState) |
BitDocSet |
getDocSetBits(Query q) |
protected DocSet |
getDocSetNC(Query query,
DocSet filter) |
FieldInfos |
getFieldInfos() |
Iterable<String> |
getFieldNames()
Returns a collection of all field names the index reader knows about.
|
SolrCache<String,UnInvertedField> |
getFieldValueCache()
expert: internal API, subject to change
|
SolrCache<Query,DocSet> |
getFilterCache() |
int |
getFirstMatch(Term t)
Returns the first document number containing the term
t Returns -1 if no document was found. |
IndexFingerprint |
getIndexFingerprint(long maxVersion) |
DirectoryReader |
getIndexReader() |
BitDocSet |
getLiveDocs()
Deprecated.
|
Bits |
getLiveDocsBits()
Returns an efficient random-access
Bits of the live docs. |
BitDocSet |
getLiveDocSet()
Returns an efficient random-access
DocSet of the live docs. |
Set<String> |
getMetricNames()
Modifiable set of metric names that this component reports (default is null,
which means none).
|
String |
getName()
Simple common usage name, e.g.
|
long |
getOpenNanoTime() |
Date |
getOpenTimeStamp() |
String |
getPath() |
SolrIndexSearcher.ProcessedFilter |
getProcessedFilter(DocSet setFilter,
List<Query> queries) |
DirectoryReader |
getRawReader()
Raw reader (no fieldcaches etc).
|
IndexSchema |
getSchema()
Direct access to the IndexSchema for use with this searcher
|
LeafReader |
getSlowAtomicReader()
Not recommended to call this method unless there is some particular reason due to internally calling
SlowCompositeReaderWrapper . |
SolrMetricsContext |
getSolrMetricsContext()
Implementing classes should override this method to provide the context obtained in
SolrMetricProducer.initializeMetrics(SolrMetricsContext, String) to ensure proper cleanup of metrics
at the end of the life-cycle of this component. |
StatsCache |
getStatsCache() |
void |
initializeMetrics(SolrMetricsContext parentContext,
String scope)
Initialize metrics specific to this producer.
|
static void |
initRegenerators(SolrConfig solrConfig) |
boolean |
intersects(DocSet a,
SolrIndexSearcher.DocsEnumState deState) |
boolean |
isCachingEnabled() |
boolean |
isLiveDocsInstantiated() |
CollectionStatistics |
localCollectionStatistics(String field) |
TermStatistics |
localTermStatistics(Term term,
int docFreq,
long totalTermFreq) |
long |
lookupId(BytesRef idBytes)
lookup the docid by the unique key field, and return the id *within* the leaf reader in the low 32 bits, and the
index of the leaf reader in the high 32 bits.
|
int |
maxDoc() |
int |
numDocs() |
int |
numDocs(DocSet a,
SolrIndexSearcher.DocsEnumState deState) |
int |
numDocs(Query a,
DocSet b)
Returns the number of documents that match both
a and b . |
int |
numDocs(Query a,
Query b)
Returns the number of documents that match both
a and b . |
void |
register()
Register sub-objects such as caches and our own metrics
|
QueryResult |
search(QueryResult qr,
QueryCommand cmd) |
void |
setLiveDocs(DocSet docs) |
protected void |
sortDocSet(QueryResult qr,
QueryCommand cmd) |
TermStatistics |
termStatistics(Term term,
int docFreq,
long totalTermFreq) |
String |
toString() |
void |
warm(SolrIndexSearcher old)
Warm this searcher based on an old one (primarily for auto-cache warming).
|
Sort |
weightSort(Sort sort)
Returns a weighted sort according to this searcher
|
SortSpec |
weightSortSpec(SortSpec originalSortSpec,
Sort nullEquivalent)
Returns a weighted sort spec according to this searcher
|
count, createWeight, explain, getDefaultQueryCache, getDefaultQueryCachingPolicy, getDefaultSimilarity, getExecutor, getQueryCache, getQueryCachingPolicy, getSimilarity, getSlices, getTopReaderContext, rewrite, search, search, search, search, search, search, searchAfter, searchAfter, searchAfter, setDefaultQueryCache, setDefaultQueryCachingPolicy, setQueryCache, setQueryCachingPolicy, setSimilarity, slices, termStatistics
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getMetricRegistry, getMetricsSnapshot, registerMetricName
getUniqueMetricTag, initializeMetrics
public static final String STATS_SOURCE
public static final String STATISTICS_KEY
public static final AtomicLong numOpens
public static final AtomicLong numCloses
public static final int NO_CHECK_QCACHE
public static final int GET_DOCSET
public static final int TERMINATE_EARLY
public static final int GET_DOCLIST
public static final int GET_SCORES
public SolrIndexSearcher(SolrCore core, String path, IndexSchema schema, SolrIndexConfig config, String name, boolean enableCache, DirectoryFactory directoryFactory) throws IOException
IOException
public SolrIndexSearcher(SolrCore core, String path, IndexSchema schema, String name, DirectoryReader r, boolean closeReader, boolean enableCache, boolean reserveDirectory, DirectoryFactory directoryFactory) throws IOException
IOException
public SolrDocumentFetcher getDocFetcher()
public StatsCache getStatsCache()
public FieldInfos getFieldInfos()
public TermStatistics termStatistics(Term term, int docFreq, long totalTermFreq) throws IOException
termStatistics
in class IndexSearcher
IOException
public CollectionStatistics collectionStatistics(String field) throws IOException
collectionStatistics
in class IndexSearcher
IOException
public TermStatistics localTermStatistics(Term term, int docFreq, long totalTermFreq) throws IOException
IOException
public CollectionStatistics localCollectionStatistics(String field) throws IOException
IOException
public boolean isCachingEnabled()
public String getPath()
public String toString()
toString
in class IndexSearcher
public SolrCore getCore()
public final int maxDoc()
public final int numDocs()
public final int docFreq(Term term) throws IOException
IOException
public final LeafReader getSlowAtomicReader()
SlowCompositeReaderWrapper
.
Use IndexSearcher.leafContexts
to get the sub readers instead of using this method.public final DirectoryReader getRawReader()
public final DirectoryReader getIndexReader()
getIndexReader
in class IndexSearcher
public void register()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface SolrMetricProducer
IOException
public IndexSchema getSchema()
public Iterable<String> getFieldNames()
public static void initRegenerators(SolrConfig solrConfig)
public QueryResult search(QueryResult qr, QueryCommand cmd) throws IOException
IOException
public Document doc(int docId) throws IOException
Document
instance corresponding to the document id.doc
in class IndexSearcher
IOException
SolrDocumentFetcher
public final void doc(int docId, StoredFieldVisitor visitor) throws IOException
StoredFieldVisitor
.
This method does not currently add to the Solr document cache.doc
in class IndexSearcher
IOException
IndexReader.document(int, StoredFieldVisitor)
,
SolrDocumentFetcher
public final Document doc(int i, Set<String> fields) throws IOException
Document
instance corresponding to the document id.
NOTE: the document will have all fields accessible, but if a field filter is provided, only the provided fields will be loaded (the remainder will be available lazily).
doc
in class IndexSearcher
IOException
SolrDocumentFetcher
public SolrCache<String,UnInvertedField> getFieldValueCache()
public Sort weightSort(Sort sort) throws IOException
IOException
public SortSpec weightSortSpec(SortSpec originalSortSpec, Sort nullEquivalent) throws IOException
IOException
public int getFirstMatch(Term t) throws IOException
t
Returns -1 if no document was found. This
method is primarily intended for clients that want to fetch documents using a unique identifier."IOException
public long lookupId(BytesRef idBytes) throws IOException
IOException
public void cacheDocSet(Query query, DocSet optionalAnswer, boolean mustCache) throws IOException
If the optionalAnswer DocSet is provided, it should *not* be modified after this call.
query
- the lucene query that will act as the keyoptionalAnswer
- the DocSet to be cached - if null, it will be computed.mustCache
- if true, a best effort will be made to cache this entry. if false, heuristics may be used to determine if
it should be cached.IOException
public BitDocSet getDocSetBits(Query q) throws IOException
IOException
public DocSet getDocSet(Query query) throws IOException
The DocSet returned should not be modified.
IOException
@Deprecated public BitDocSet getLiveDocs() throws IOException
IOException
public BitDocSet getLiveDocSet() throws IOException
DocSet
of the live docs. It's cached. Never null.IOException
public Bits getLiveDocsBits() throws IOException
Bits
of the live docs. It's cached. Null means all docs are live.
Use this like LeafReader.getLiveDocs()
.IOException
public boolean isLiveDocsInstantiated()
public void setLiveDocs(DocSet docs)
public DocSet getDocSet(List<Query> queries) throws IOException
The DocSet returned should not be modified.
IOException
public SolrIndexSearcher.ProcessedFilter getProcessedFilter(DocSet setFilter, List<Query> queries) throws IOException
IOException
public DocSet getDocSet(SolrIndexSearcher.DocsEnumState deState) throws IOException
IOException
protected DocSet getDocSetNC(Query query, DocSet filter) throws IOException
IOException
public DocSet getDocSet(Query query, DocSet filter) throws IOException
filter
- may be nullIOException
public DocList getDocList(Query query, Query filter, Sort lsort, int offset, int len) throws IOException
query
and filter
and sorted by sort
.
This method is cache aware and may retrieve filter
from the cache or make an insertion into the cache
as a result of this call.
FUTURE: The returned DocList may be retrieved from a cache.
filter
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnIOException
- If there is a low-level I/O error.public DocList getDocList(Query query, List<Query> filterList, Sort lsort, int offset, int len, int flags) throws IOException
query
and the intersection of the filterList
, sorted by
sort
.
This method is cache aware and may retrieve filter
from the cache or make an insertion into the cache
as a result of this call.
FUTURE: The returned DocList may be retrieved from a cache.
filterList
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnIOException
- If there is a low-level I/O error.public DocList getDocList(Query query, DocSet filter, Sort lsort, int offset, int len) throws IOException
query
and filter
and sorted by sort
. FUTURE:
The returned DocList may be retrieved from a cache.filter
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnIOException
- If there is a low-level I/O error.public DocListAndSet getDocListAndSet(Query query, Query filter, Sort lsort, int offset, int len) throws IOException
query
and filter
and sorted by sort
. Also
returns the complete set of documents matching query
and filter
(regardless of
offset
and len
).
This method is cache aware and may retrieve filter
from the cache or make an insertion into the cache
as a result of this call.
FUTURE: The returned DocList may be retrieved from a cache.
The DocList and DocSet returned should not be modified.
filter
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnIOException
- If there is a low-level I/O error.public DocListAndSet getDocListAndSet(Query query, Query filter, Sort lsort, int offset, int len, int flags) throws IOException
query
and filter
and sorted by sort
. Also
returns the compete set of documents matching query
and filter
(regardless of
offset
and len
).
This method is cache aware and may retrieve filter
from the cache or make an insertion into the cache
as a result of this call.
FUTURE: The returned DocList may be retrieved from a cache.
The DocList and DocSet returned should not be modified.
filter
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnflags
- user supplied flags for the result setIOException
- If there is a low-level I/O error.public DocListAndSet getDocListAndSet(Query query, List<Query> filterList, Sort lsort, int offset, int len) throws IOException
query
and the intersection of filterList
, sorted by
sort
. Also returns the compete set of documents matching query
and filter
(regardless of offset
and len
).
This method is cache aware and may retrieve filter
from the cache or make an insertion into the cache
as a result of this call.
FUTURE: The returned DocList may be retrieved from a cache.
The DocList and DocSet returned should not be modified.
filterList
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnIOException
- If there is a low-level I/O error.public DocListAndSet getDocListAndSet(Query query, List<Query> filterList, Sort lsort, int offset, int len, int flags) throws IOException
query
and the intersection of filterList
, sorted by
sort
. Also returns the compete set of documents matching query
and filter
(regardless of offset
and len
).
This method is cache aware and may retrieve filter
from the cache or make an insertion into the cache
as a result of this call.
FUTURE: The returned DocList may be retrieved from a cache.
The DocList and DocSet returned should not be modified.
filterList
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnflags
- user supplied flags for the result setIOException
- If there is a low-level I/O error.public DocListAndSet getDocListAndSet(Query query, DocSet filter, Sort lsort, int offset, int len) throws IOException
query
and filter
and sorted by sort
. Also
returns the compete set of documents matching query
and filter
(regardless of
offset
and len
).
FUTURE: The returned DocList may be retrieved from a cache.
filter
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnIOException
- If there is a low-level I/O error.public DocListAndSet getDocListAndSet(Query query, DocSet filter, Sort lsort, int offset, int len, int flags) throws IOException
query
and filter
and sorted by sort
. Also
returns the compete set of documents matching query
and filter
(regardless of
offset
and len
).
This method is cache aware and may make an insertion into the cache as a result of this call.
FUTURE: The returned DocList may be retrieved from a cache.
The DocList and DocSet returned should not be modified.
filter
- may be nulllsort
- criteria by which to sort (if null, query relevance is used)offset
- offset into the list of documents to returnlen
- maximum number of documents to returnflags
- user supplied flags for the result setIOException
- If there is a low-level I/O error.protected void sortDocSet(QueryResult qr, QueryCommand cmd) throws IOException
IOException
public int numDocs(Query a, DocSet b) throws IOException
a
and b
.
This method is cache-aware and may check as well as modify the cache.
a
and b
.IOException
- If there is a low-level I/O error.public int numDocs(DocSet a, SolrIndexSearcher.DocsEnumState deState) throws IOException
IOException
public int numDocs(Query a, Query b) throws IOException
a
and b
.
This method is cache-aware and may check as well as modify the cache.
a
and b
.IOException
- If there is a low-level I/O error.public boolean intersects(DocSet a, SolrIndexSearcher.DocsEnumState deState) throws IOException
IOException
public void warm(SolrIndexSearcher old)
public Object cacheLookup(String cacheName, Object key)
public Object cacheInsert(String cacheName, Object key, Object val)
public Date getOpenTimeStamp()
public long getOpenNanoTime()
public Explanation explain(Query query, int doc) throws IOException
explain
in class IndexSearcher
IOException
public IndexFingerprint getIndexFingerprint(long maxVersion) throws IOException
IOException
public String getName()
SolrInfoBean
getName
in interface SolrInfoBean
public String getDescription()
SolrInfoBean
getDescription
in interface SolrInfoBean
public SolrInfoBean.Category getCategory()
SolrInfoBean
getCategory
in interface SolrInfoBean
public Set<String> getMetricNames()
SolrInfoBean
SolrInfoBean.registerMetricName(String)
to capture what metrics names are reported from this component.
NOTE: this set has to allow iteration under modifications.
getMetricNames
in interface SolrInfoBean
public SolrMetricsContext getSolrMetricsContext()
SolrMetricProducer
SolrMetricProducer.initializeMetrics(SolrMetricsContext, String)
to ensure proper cleanup of metrics
at the end of the life-cycle of this component.getSolrMetricsContext
in interface SolrMetricProducer
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
SolrMetricProducer
initializeMetrics
in interface SolrMetricProducer
parentContext
- parent metrics context. If this component has the same life-cycle as the parent
it can simply use the parent context, otherwise it should obtain a child context
using SolrMetricsContext.getChildContext(Object)
passing this
as the child.scope
- component scopeCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.