Author: yonik
Date: Wed Sep 13 13:55:46 2006
New Revision: 443119

URL: http://svn.apache.org/viewvc?view=rev&rev=443119
Log:
getDocSet optimized for TermQuery

Modified:
    incubator/solr/trunk/CHANGES.txt
    incubator/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java

Modified: incubator/solr/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/solr/trunk/CHANGES.txt?view=diff&rev=443119&r1=443118&r2=443119
==============================================================================
--- incubator/solr/trunk/CHANGES.txt (original)
+++ incubator/solr/trunk/CHANGES.txt Wed Sep 13 13:55:46 2006
@@ -80,6 +80,9 @@
     Iteration is faster, and BitDocSet.intersectionSize(BitDocSet) and 
unionSize
     is between 3 and 4 times faster. (yonik, SOLR-15)
  4. much faster unionSize when one of the sets is a HashDocSet: 
O(smaller_set_size)
+ 5. Optimized getDocSet() for term queries resulting in a 36% speedup of 
facet.field
+    queries where DocSets aren't cached (for example, if the number of terms 
in the field
+    is larger than the filter cache.) (yonik)
 
 Bug Fixes
  1. Fixed delete-by-id for field types who's indexed form is different

Modified: 
incubator/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: 
http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java?view=diff&rev=443119&r1=443118&r2=443119
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java 
(original)
+++ incubator/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java 
Wed Sep 13 13:55:46 2006
@@ -458,12 +458,23 @@
   }
 
 
-
   protected DocSet getDocSetNC(Query query, DocSet filter) throws IOException {
     if (filter==null) {
       DocSetHitCollector hc = new DocSetHitCollector(maxDoc());
-      searcher.search(query,null,hc);
+      if (query instanceof TermQuery) {
+        Term t = ((TermQuery)query).getTerm();
+        TermDocs tdocs = null;
+        try {
+          tdocs = reader.termDocs(t);
+          while (tdocs.next()) hc.collect(tdocs.doc(),0.0f);
+        } finally {
+          if (tdocs!=null) tdocs.close();
+        }
+      } else {
+        searcher.search(query,null,hc);
+      }
       return hc.getDocSet();
+
     } else {
       // FUTURE: if the filter is sorted by docid, could use skipTo 
(SkipQueryFilter)
       final DocSetHitCollector hc = new DocSetHitCollector(maxDoc());
@@ -1041,7 +1052,6 @@
   /**
    * A simple utility method for to build a filterList from a query
    * @param filter
-   * @return
    */
   private List<Query> buildQueryList(Query filter) {
        List<Query> filterList = null;


Reply via email to