|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lucene.search.Searcher
org.apache.solr.search.SolrIndexSearcher
public class SolrIndexSearcher
SolrIndexSearcher adds schema awareness and caching functionality over the lucene IndexSearcher.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoMBean |
---|
SolrInfoMBean.Category |
Field Summary | |
---|---|
static boolean |
enableLazyFieldLoading
|
static int |
GET_SCORES
|
Constructor Summary | |
---|---|
SolrIndexSearcher(IndexSchema schema,
String name,
Directory directory,
boolean enableCache)
Creates a searcher searching the index in the provided directory. |
|
SolrIndexSearcher(IndexSchema schema,
String name,
IndexReader r,
boolean enableCache)
Creates a searcher searching the provided index. |
|
SolrIndexSearcher(IndexSchema schema,
String name,
String path,
boolean enableCache)
Creates a searcher searching the index in the named directory. |
Method Summary | |
---|---|
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. |
DocSet |
convertFilter(Filter lfilter)
Converts a filter into a DocSet. |
Document |
doc(int i)
Retrieve the Document instance corresponding to the document id. |
Document |
doc(int n,
FieldSelector fieldSelector)
Retrieve a Document using a FieldSelector
This method does not currently use the Solr document cache. |
Document |
doc(int i,
Set<String> fields)
Retrieve the Document instance corresponding to the document id. |
int |
docFreq(Term term)
|
Explanation |
explain(Weight weight,
int i)
|
SolrCache |
getCache(String cacheName)
return the named generic cache |
SolrInfoMBean.Category |
getCategory()
Purpose of this Class |
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. |
protected DocSet |
getDocSet(List<Query> 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. |
protected DocSet |
getDocSetNC(Query query,
DocSet filter)
|
int |
getFirstMatch(Term t)
Returns the first document number containing the term t
Returns -1 if no document was found. |
String |
getName()
Simple common usage name, e.g. |
IndexReader |
getReader()
Direct access to the IndexReader used by this searcher |
IndexSchema |
getSchema()
Direct access to the IndexSchema for use with this searcher |
Similarity |
getSimilarity()
|
String |
getSource()
CVS Source, SVN Source, etc |
String |
getSourceId()
CVS Id, SVN Id, etc |
NamedList |
getStatistics()
Any statistics this instance would like to be publicly available via the Solr Administration interface. |
String |
getVersion()
Simple common usage version, e.g. |
int |
maxDoc()
|
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 |
Query |
rewrite(Query original)
|
Hits |
search(Query query,
Filter filter)
|
Hits |
search(Query query,
Filter filter,
Sort sort)
|
void |
search(Query query,
HitCollector results)
|
Hits |
search(Query query,
Sort sort)
|
void |
search(Weight weight,
Filter filter,
HitCollector hitCollector)
|
TopDocs |
search(Weight weight,
Filter filter,
int i)
|
TopFieldDocs |
search(Weight weight,
Filter filter,
int i,
Sort sort)
|
void |
setSimilarity(Similarity similarity)
|
protected DocList |
sortDocSet(DocSet set,
Sort sort,
int nDocs)
|
String |
toString()
|
void |
warm(SolrIndexSearcher old)
Warm this searcher based on an old one (primarily for auto-cache warming). |
Methods inherited from class org.apache.lucene.search.Searcher |
---|
createWeight, docFreqs, explain, search, search, search, search |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final boolean enableLazyFieldLoading
public static final int GET_SCORES
Constructor Detail |
---|
public SolrIndexSearcher(IndexSchema schema, String name, String path, boolean enableCache) throws IOException
IOException
public SolrIndexSearcher(IndexSchema schema, String name, Directory directory, boolean enableCache) throws IOException
IOException
public SolrIndexSearcher(IndexSchema schema, String name, IndexReader r, boolean enableCache)
Method Detail |
---|
public String toString()
toString
in class Object
public void register()
public void close() throws IOException
close
in interface Searchable
close
in class Searcher
IOException
public IndexReader getReader()
public IndexSchema getSchema()
public Hits search(Query query, Filter filter, Sort sort) throws IOException
search
in class Searcher
IOException
public Hits search(Query query, Filter filter) throws IOException
search
in class Searcher
IOException
public Hits search(Query query, Sort sort) throws IOException
search
in class Searcher
IOException
public void search(Query query, HitCollector results) throws IOException
search
in class Searcher
IOException
public void setSimilarity(Similarity similarity)
setSimilarity
in class Searcher
public Similarity getSimilarity()
getSimilarity
in class Searcher
public int docFreq(Term term) throws IOException
docFreq
in interface Searchable
docFreq
in class Searcher
IOException
public Document doc(int i) throws IOException
Document
instance corresponding to the document id.
doc
in interface Searchable
doc
in class Searcher
IOException
public Document doc(int n, FieldSelector fieldSelector) throws IOException
Document
using a FieldSelector
This method does not currently use the Solr document cache.
doc
in interface Searchable
IOException
IndexReader.document(int, FieldSelector)
public Document doc(int i, Set<String> fields) throws IOException
Document
instance corresponding to the document id.
Note: The document will have all fields accessable, but if a field
filter is provided, only the provided fields will be loaded (the
remainder will be available lazily).
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 int maxDoc() throws IOException
maxDoc
in interface Searchable
maxDoc
in class Searcher
IOException
public TopDocs search(Weight weight, Filter filter, int i) throws IOException
search
in interface Searchable
search
in class Searcher
IOException
public void search(Weight weight, Filter filter, HitCollector hitCollector) throws IOException
search
in interface Searchable
search
in class Searcher
IOException
public Query rewrite(Query original) throws IOException
rewrite
in interface Searchable
rewrite
in class Searcher
IOException
public Explanation explain(Weight weight, int i) throws IOException
explain
in interface Searchable
explain
in class Searcher
IOException
public TopFieldDocs search(Weight weight, Filter filter, int i, Sort sort) throws IOException
search
in interface Searchable
search
in class Searcher
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."
t
-
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
protected DocSet getDocSet(List<Query> queries) throws IOException
IOException
protected DocSet getDocSetNC(Query query, DocSet filter) throws IOException
IOException
public DocSet getDocSet(Query query, DocSet filter) throws IOException
query
- filter
- may be null
IOException
public DocSet convertFilter(Filter lfilter) throws IOException
IOException
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.
query
- 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 return
IOException
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.
query
- 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 return
IOException
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.
query
- 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 return
IOException
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 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.
query
- 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 return
IOException
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.
query
- 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 set
IOException
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.
query
- 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 return
IOException
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.
query
- 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 set
IOException
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.
query
- 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 return
IOException
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.
query
- 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 set
IOException
protected DocList sortDocSet(DocSet set, Sort sort, int nDocs) 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
- b
-
a
and b
.
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
- b
-
a
and b
.
IOException
public Document[] readDocs(DocList ids) throws IOException
IOException
public void warm(SolrIndexSearcher old) throws IOException
IOException
public SolrCache getCache(String cacheName)
public Object cacheLookup(String cacheName, Object key)
public Object cacheInsert(String cacheName, Object key, Object val)
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 getSourceId()
SolrInfoMBean
getSourceId
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 getStatistics()
SolrInfoMBean
Any Object type may be stored in the list, but only the
toString()
representation will be used.
getStatistics
in interface SolrInfoMBean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |