Class SolrIndexSearcher

    • Method Detail

      • getStatsCache

        public StatsCache getStatsCache()
      • getFieldInfos

        public org.apache.lucene.index.FieldInfos getFieldInfos()
      • termStatistics

        public org.apache.lucene.search.TermStatistics termStatistics​(org.apache.lucene.index.Term term,
                                                                      int docFreq,
                                                                      long totalTermFreq)
                                                               throws IOException
        Overrides:
        termStatistics in class org.apache.lucene.search.IndexSearcher
        Throws:
        IOException
      • collectionStatistics

        public org.apache.lucene.search.CollectionStatistics collectionStatistics​(String field)
                                                                           throws IOException
        Overrides:
        collectionStatistics in class org.apache.lucene.search.IndexSearcher
        Throws:
        IOException
      • localTermStatistics

        public org.apache.lucene.search.TermStatistics localTermStatistics​(org.apache.lucene.index.Term term,
                                                                           int docFreq,
                                                                           long totalTermFreq)
                                                                    throws IOException
        Throws:
        IOException
      • localCollectionStatistics

        public org.apache.lucene.search.CollectionStatistics localCollectionStatistics​(String field)
                                                                                throws IOException
        Throws:
        IOException
      • isCachingEnabled

        public boolean isCachingEnabled()
      • getPath

        public String getPath()
      • toString

        public String toString()
        Overrides:
        toString in class org.apache.lucene.search.IndexSearcher
      • maxDoc

        public final int maxDoc()
      • numDocs

        public final int numDocs()
      • docFreq

        public final int docFreq​(org.apache.lucene.index.Term term)
                          throws IOException
        Throws:
        IOException
      • getSlowAtomicReader

        public final org.apache.lucene.index.LeafReader getSlowAtomicReader()
        Not recommended to call this method unless there is some particular reason due to internally calling SlowCompositeReaderWrapper. Use IndexSearcher.leafContexts to get the sub readers instead of using this method.
      • getRawReader

        public final org.apache.lucene.index.DirectoryReader getRawReader()
        Raw reader (no fieldcaches etc). Useful for operations like addIndexes
      • getIndexReader

        public final org.apache.lucene.index.DirectoryReader getIndexReader()
        Overrides:
        getIndexReader in class org.apache.lucene.search.IndexSearcher
      • register

        public void register()
        Register sub-objects such as caches and our own metrics
      • getSchema

        public IndexSchema getSchema()
        Direct access to the IndexSchema for use with this searcher
      • getFieldNames

        public Iterable<String> getFieldNames()
        Returns a collection of all field names the index reader knows about.
      • getFilterCache

        public SolrCache<org.apache.lucene.search.Query,​DocSet> getFilterCache()
      • initRegenerators

        public static void initRegenerators​(SolrConfig solrConfig)
      • search

        protected void search​(List<org.apache.lucene.index.LeafReaderContext> leaves,
                              org.apache.lucene.search.Weight weight,
                              org.apache.lucene.search.Collector collector)
                       throws IOException
        Overrides:
        search in class org.apache.lucene.search.IndexSearcher
        Throws:
        IOException
      • doc

        public org.apache.lucene.document.Document doc​(int docId)
                                                throws IOException
        Retrieve the Document instance corresponding to the document id.
        Overrides:
        doc in class org.apache.lucene.search.IndexSearcher
        Throws:
        IOException
        See Also:
        SolrDocumentFetcher
      • doc

        public final void doc​(int docId,
                              org.apache.lucene.index.StoredFieldVisitor visitor)
                       throws IOException
        Visit a document's fields using a StoredFieldVisitor. This method does not currently add to the Solr document cache.
        Overrides:
        doc in class org.apache.lucene.search.IndexSearcher
        Throws:
        IOException
        See Also:
        IndexReader.document(int, StoredFieldVisitor), SolrDocumentFetcher
      • doc

        public final org.apache.lucene.document.Document doc​(int i,
                                                             Set<String> fields)
                                                      throws IOException
        Retrieve the 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).

        Overrides:
        doc in class org.apache.lucene.search.IndexSearcher
        Throws:
        IOException
        See Also:
        SolrDocumentFetcher
      • weightSort

        public org.apache.lucene.search.Sort weightSort​(org.apache.lucene.search.Sort sort)
                                                 throws IOException
        Returns a weighted sort according to this searcher
        Throws:
        IOException
      • weightSortSpec

        public SortSpec weightSortSpec​(SortSpec originalSortSpec,
                                       org.apache.lucene.search.Sort nullEquivalent)
                                throws IOException
        Returns a weighted sort spec according to this searcher
        Throws:
        IOException
      • getFirstMatch

        public int getFirstMatch​(org.apache.lucene.index.Term t)
                          throws IOException
        Returns the first document number containing the term t Returns -1 if no document was found. This method is primarily intended for clients that want to fetch documents using a unique identifier."
        Returns:
        the first document number containing the term
        Throws:
        IOException
      • lookupId

        public long lookupId​(org.apache.lucene.util.BytesRef idBytes)
                      throws IOException
        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. -1 is returned if not found.
        Throws:
        IOException
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
      • cacheDocSet

        public void cacheDocSet​(org.apache.lucene.search.Query query,
                                DocSet optionalAnswer,
                                boolean mustCache)
                         throws IOException
        Compute and cache the DocSet that matches a query. The normal usage is expected to be cacheDocSet(myQuery, null,false) meaning that Solr will determine if the Query warrants caching, and if so, will compute the DocSet that matches the Query and cache it. If the answer to the query is already cached, nothing further will be done.

        If the optionalAnswer DocSet is provided, it should *not* be modified after this call.

        Parameters:
        query - the lucene query that will act as the key
        optionalAnswer - 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.
        Throws:
        IOException
      • getLiveDocSet

        public BitDocSet getLiveDocSet()
                                throws IOException
        Returns an efficient random-access DocSet of the live docs. It's cached. Never null.
        Throws:
        IOException
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
        the type of DocSet returned may change in the future
      • getLiveDocsBits

        public org.apache.lucene.util.Bits getLiveDocsBits()
                                                    throws IOException
        Returns an efficient random-access Bits of the live docs. It's cached. Null means all docs are live. Use this like LeafReader.getLiveDocs().
        Throws:
        IOException
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
      • offerLiveDocs

        public BitDocSet offerLiveDocs​(Supplier<DocSet> docSetSupplier,
                                       int suppliedSize)
        If some process external to SolrIndexSearcher has produced a DocSet whose cardinality matches that of `liveDocs`, this method provides such caller the ability to offer its own DocSet to be cached in the searcher. The caller should then use the returned value (which may or may not be derived from the DocSet instance supplied), allowing more efficient memory use.
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
      • getDocSet

        public DocSet getDocSet​(List<org.apache.lucene.search.Query> queries)
                         throws IOException
        Returns the set of document ids matching all queries. This method is cache-aware and attempts to retrieve the answer from the cache if possible. If the answer was not cached, it may have been inserted into the cache as a result of this call. This method can handle negative queries. A null/empty list results in getLiveDocSet().

        The DocSet returned should not be modified.

        Throws:
        IOException
      • getDocSet

        public DocSet getDocSet​(org.apache.lucene.search.Query query)
                         throws IOException
        Returns the set of document ids matching both the query. This method is cache-aware and attempts to retrieve a DocSet of the query from the cache if possible. If the answer was not cached, it may have been inserted into the cache as a result of this call.
        Returns:
        Non-null DocSet meeting the specified criteria. Should not be modified by the caller.
        Throws:
        IOException
        See Also:
        getDocSet(Query,DocSet)
      • getDocSet

        public DocSet getDocSet​(org.apache.lucene.search.Query query,
                                DocSet filter)
                         throws IOException
        Returns the set of document ids matching both the query and the filter. This method is cache-aware and attempts to retrieve a DocSet of the query from the cache if possible. If the answer was not cached, it may have been inserted into the cache as a result of this call.
        Parameters:
        filter - may be null if none
        Returns:
        Non-null DocSet meeting the specified criteria. Should not be modified by the caller.
        Throws:
        IOException
      • getDocList

        public DocList getDocList​(org.apache.lucene.search.Query query,
                                  org.apache.lucene.search.Query filter,
                                  org.apache.lucene.search.Sort lsort,
                                  int offset,
                                  int len)
                           throws IOException
        Returns documents matching both 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.

        Parameters:
        filter - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        Returns:
        DocList meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocList

        public DocList getDocList​(org.apache.lucene.search.Query query,
                                  List<org.apache.lucene.search.Query> filterList,
                                  org.apache.lucene.search.Sort lsort,
                                  int offset,
                                  int len,
                                  int flags)
                           throws IOException
        Returns documents matching both 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.

        Parameters:
        filterList - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        Returns:
        DocList meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocList

        public DocList getDocList​(org.apache.lucene.search.Query query,
                                  DocSet filter,
                                  org.apache.lucene.search.Sort lsort,
                                  int offset,
                                  int len)
                           throws IOException
        Returns documents matching both query and filter and sorted by sort. FUTURE: The returned DocList may be retrieved from a cache.
        Parameters:
        filter - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        Returns:
        DocList meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocListAndSet

        public DocListAndSet getDocListAndSet​(org.apache.lucene.search.Query query,
                                              org.apache.lucene.search.Query filter,
                                              org.apache.lucene.search.Sort lsort,
                                              int offset,
                                              int len)
                                       throws IOException
        Returns documents matching both 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.

        Parameters:
        filter - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        Returns:
        DocListAndSet meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocListAndSet

        public DocListAndSet getDocListAndSet​(org.apache.lucene.search.Query query,
                                              org.apache.lucene.search.Query filter,
                                              org.apache.lucene.search.Sort lsort,
                                              int offset,
                                              int len,
                                              int flags)
                                       throws IOException
        Returns documents matching both 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.

        Parameters:
        filter - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        flags - user supplied flags for the result set
        Returns:
        DocListAndSet meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocListAndSet

        public DocListAndSet getDocListAndSet​(org.apache.lucene.search.Query query,
                                              List<org.apache.lucene.search.Query> filterList,
                                              org.apache.lucene.search.Sort lsort,
                                              int offset,
                                              int len)
                                       throws IOException
        Returns documents matching both 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.

        Parameters:
        filterList - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        Returns:
        DocListAndSet meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocListAndSet

        public DocListAndSet getDocListAndSet​(org.apache.lucene.search.Query query,
                                              List<org.apache.lucene.search.Query> filterList,
                                              org.apache.lucene.search.Sort lsort,
                                              int offset,
                                              int len,
                                              int flags)
                                       throws IOException
        Returns documents matching both 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.

        Parameters:
        filterList - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        flags - user supplied flags for the result set
        Returns:
        DocListAndSet meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocListAndSet

        public DocListAndSet getDocListAndSet​(org.apache.lucene.search.Query query,
                                              DocSet filter,
                                              org.apache.lucene.search.Sort lsort,
                                              int offset,
                                              int len)
                                       throws IOException
        Returns documents matching both 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.

        Parameters:
        filter - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        Returns:
        DocListAndSet meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • getDocListAndSet

        public DocListAndSet getDocListAndSet​(org.apache.lucene.search.Query query,
                                              DocSet filter,
                                              org.apache.lucene.search.Sort lsort,
                                              int offset,
                                              int len,
                                              int flags)
                                       throws IOException
        Returns documents matching both 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.

        Parameters:
        filter - may be null
        lsort - criteria by which to sort (if null, query relevance is used)
        offset - offset into the list of documents to return
        len - maximum number of documents to return
        flags - user supplied flags for the result set
        Returns:
        DocListAndSet meeting the specified criteria, should not be modified by the caller.
        Throws:
        IOException - If there is a low-level I/O error.
      • numDocs

        public int numDocs​(org.apache.lucene.search.Query a,
                           DocSet b)
                    throws IOException
        Returns the number of documents that match both a and b.

        This method is cache-aware and may check as well as modify the cache.

        Returns:
        the number of documents in the intersection between a and b.
        Throws:
        IOException - If there is a low-level I/O error.
      • numDocs

        public int numDocs​(org.apache.lucene.search.Query a,
                           org.apache.lucene.search.Query b)
                    throws IOException
        Returns the number of documents that match both a and b.

        This method is cache-aware and may check as well as modify the cache.

        Returns:
        the number of documents in the intersection between a and b.
        Throws:
        IOException - If there is a low-level I/O error.
      • bootstrapFirstSearcher

        public void bootstrapFirstSearcher()
        Called on the initial searcher for each core, immediately before firstSearcherListeners are called for the searcher. This provides the opportunity to perform initialization on the first registered searcher before the searcher begins to see any firstSearcher -triggered events.
      • warm

        public void warm​(SolrIndexSearcher old)
        Warm this searcher based on an old one (primarily for auto-cache warming).
      • getCache

        public SolrCache getCache​(String cacheName)
        return the named generic cache
      • cacheLookup

        public Object cacheLookup​(String cacheName,
                                  Object key)
        lookup an entry in a generic cache
      • cacheInsert

        public Object cacheInsert​(String cacheName,
                                  Object key,
                                  Object val)
        insert an entry in a generic cache
      • getOpenTimeStamp

        public Date getOpenTimeStamp()
      • getOpenNanoTime

        public long getOpenNanoTime()
      • explain

        public org.apache.lucene.search.Explanation explain​(org.apache.lucene.search.Query query,
                                                            int doc)
                                                     throws IOException
        Overrides:
        explain in class org.apache.lucene.search.IndexSearcher
        Throws:
        IOException
      • getIndexFingerprint

        public IndexFingerprint getIndexFingerprint​(long maxVersion)
                                             throws IOException
        Throws:
        IOException
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
        gets a cached version of the IndexFingerprint for this searcher
      • getName

        public String getName()
        Description copied from interface: SolrInfoBean
        Simple common usage name, e.g. BasicQueryHandler, or fully qualified class name.
        Specified by:
        getName in interface SolrInfoBean
      • getWarmupTime

        public long getWarmupTime()