public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrInfoMBean
Modifier and Type | Class and Description |
---|---|
static class |
SolrIndexSearcher.DocsEnumState |
static class |
SolrIndexSearcher.ProcessedFilter |
static class |
SolrIndexSearcher.QueryCommand
A query request command to avoid having to change the method signatures
if we want to pass additional information to the searcher.
|
static class |
SolrIndexSearcher.QueryResult
The result of a search.
|
IndexSearcher.LeafSlice
SolrInfoMBean.Category
Modifier and Type | Field and Description |
---|---|
boolean |
enableLazyFieldLoading |
static int |
GET_DOCLIST |
static int |
GET_DOCSET |
static int |
GET_SCORES |
static AtomicLong |
numCloses |
static AtomicLong |
numOpens |
static int |
TERMINATE_EARLY |
leafContexts, leafSlices, 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,
SolrIndexConfig config,
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.
|
Document |
doc(int i)
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 n,
StoredFieldVisitor visitor)
Visit a document's fields using a
StoredFieldVisitor
This method does not currently add to the Solr document cache. |
int |
docFreq(Term term) |
Explanation |
explain(Query query,
int doc) |
AtomicReader |
getAtomicReader() |
SolrCache |
getCache(String cacheName)
return the named generic cache
|
SolrInfoMBean.Category |
getCategory()
Purpose of this Class
|
SolrCore |
getCore() |
String |
getDescription()
Simple one or two line description
|
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 . |
URL[] |
getDocs()
Documentation URL list.
|
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)
lucene.internal
|
protected DocSet |
getDocSetNC(Query query,
DocSet filter) |
Collection<String> |
getFieldNames()
Returns a collection of all field names the index reader knows about.
|
SolrCache<String,UnInvertedField> |
getFieldValueCache()
expert: internal API, subject to change
|
int |
getFirstMatch(Term t)
Returns the first document number containing the term
t
Returns -1 if no document was found. |
DirectoryReader |
getIndexReader() |
String |
getName()
Simple common usage name, e.g.
|
long |
getOpenTime() |
String |
getPath() |
SolrIndexSearcher.ProcessedFilter |
getProcessedFilter(DocSet setFilter,
List<Query> queries) |
IndexSchema |
getSchema()
Direct access to the IndexSchema for use with this searcher
|
String |
getSource()
CVS Source, SVN Source, etc
|
NamedList<Object> |
getStatistics()
Any statistics this instance would like to be publicly available via
the Solr Administration interface.
|
Collection<String> |
getStoredHighlightFieldNames()
Returns a collection of the names of all stored fields which can be
highlighted the index reader knows about.
|
String |
getVersion()
Simple common usage version, e.g.
|
static void |
initRegenerators(SolrConfig solrConfig) |
boolean |
isCachingEnabled() |
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(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 . |
Document[] |
readDocs(DocList ids)
Takes a list of docs (the doc ids actually), and returns an array
of Documents containing all of the stored fields.
|
void |
readDocs(Document[] docs,
DocList ids)
Takes a list of docs (the doc ids actually), and reads them into an array
of Documents.
|
void |
readDocs(Document[] docs,
DocList ids,
Set<String> fields)
Takes a list of docs (the doc ids actually) and a set of fields to load,
and reads them into an array of Documents.
|
void |
register()
Register sub-objects such as caches
|
SolrIndexSearcher.QueryResult |
search(SolrIndexSearcher.QueryResult qr,
SolrIndexSearcher.QueryCommand cmd) |
protected void |
sortDocSet(SolrIndexSearcher.QueryResult qr,
SolrIndexSearcher.QueryCommand cmd) |
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
|
collectionStatistics, createNormalizedWeight, document, explain, getDefaultSimilarity, getSimilarity, getTopReaderContext, rewrite, search, search, search, search, search, search, search, search, search, search, search, search, search, searchAfter, searchAfter, searchAfter, searchAfter, searchAfter, setSimilarity, slices, termStatistics, wrapFilter
public static final AtomicLong numOpens
public static final AtomicLong numCloses
public final boolean enableLazyFieldLoading
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, SolrIndexConfig config, String name, DirectoryReader r, boolean closeReader, boolean enableCache, boolean reserveDirectory, DirectoryFactory directoryFactory) 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 docFreq(Term term) throws IOException
IOException
public final AtomicReader getAtomicReader()
public final DirectoryReader getIndexReader()
getIndexReader
in class IndexSearcher
public void register()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public IndexSchema getSchema()
public Collection<String> getFieldNames()
public Collection<String> getStoredHighlightFieldNames()
public static void initRegenerators(SolrConfig solrConfig)
public SolrIndexSearcher.QueryResult search(SolrIndexSearcher.QueryResult qr, SolrIndexSearcher.QueryCommand cmd) throws IOException
IOException
public Document doc(int i) throws IOException
Document
instance corresponding to the document id.doc
in class IndexSearcher
IOException
public void doc(int n, 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)
public 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
public void readDocs(Document[] docs, DocList ids) throws IOException
IOException
public void readDocs(Document[] docs, DocList ids, Set<String> fields) throws IOException
IOException
public SolrCache<String,UnInvertedField> getFieldValueCache()
public Sort weightSort(Sort sort) 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 DocSet getDocSet(Query query) throws IOException
The DocSet returned should not be modified.
IOException
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(SolrIndexSearcher.QueryResult qr, SolrIndexSearcher.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 Document[] readDocs(DocList ids) throws IOException
IOException
public void warm(SolrIndexSearcher old) throws IOException
IOException
public Object cacheLookup(String cacheName, Object key)
public Object cacheInsert(String cacheName, Object key, Object val)
public long getOpenTime()
public Explanation explain(Query query, int doc) throws IOException
explain
in class IndexSearcher
IOException
public String getName()
SolrInfoMBean
getName
in interface SolrInfoMBean
public String getVersion()
SolrInfoMBean
getVersion
in interface SolrInfoMBean
public String getDescription()
SolrInfoMBean
getDescription
in interface SolrInfoMBean
public SolrInfoMBean.Category getCategory()
SolrInfoMBean
getCategory
in interface SolrInfoMBean
public String getSource()
SolrInfoMBean
getSource
in interface SolrInfoMBean
public URL[] getDocs()
SolrInfoMBean
Suggested documentation URLs: Homepage for sponsoring project, FAQ on class usage, Design doc for class, Wiki, bug reporting URL, etc...
getDocs
in interface SolrInfoMBean
public NamedList<Object> getStatistics()
SolrInfoMBean
Any Object type may be stored in the list, but only the
toString()
representation will be used.
getStatistics
in interface SolrInfoMBean
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.