lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbern...@apache.org
Subject [10/11] lucene-solr:branch_6x: SOLR-9027: Collect the TermContexts in createWeight
Date Mon, 02 May 2016 13:29:41 GMT
SOLR-9027: Collect the TermContexts in createWeight


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/3cc4125a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3cc4125a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3cc4125a

Branch: refs/heads/branch_6x
Commit: 3cc4125a8a04fb71be71b1eb1222a860d3d646e4
Parents: 86f371c
Author: jbernste <jbernste@apache.org>
Authored: Fri Apr 29 10:13:23 2016 -0400
Committer: jbernste <jbernste@apache.org>
Committed: Mon May 2 08:45:07 2016 -0400

----------------------------------------------------------------------
 .../solr/search/GraphTermsQParserPlugin.java    | 29 ++++++++++----------
 1 file changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3cc4125a/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
index 01dfa2d..05a4c32 100644
--- a/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
@@ -100,8 +100,6 @@ public class GraphTermsQParserPlugin extends QParserPlugin {
   private class GraphTermsQuery extends Query implements ExtendedQuery {
 
     private Term[] queryTerms;
-    private List<TermContext> finalContexts;
-    private List<Term> finalTerms;
     private String field;
     private int maxDocFreq;
     private Object id;
@@ -147,19 +145,6 @@ public class GraphTermsQParserPlugin extends QParserPlugin {
 
     @Override
     public Query rewrite(IndexReader reader) throws IOException {
-      this.finalContexts = new ArrayList();
-      this.finalTerms = new ArrayList();
-      List<LeafReaderContext> contexts = reader.leaves();
-      TermContext[] termContexts = new TermContext[this.queryTerms.length];
-      collectTermContext(reader, contexts, termContexts, this.queryTerms);
-      for(int i=0; i<termContexts.length; i++) {
-        TermContext termContext = termContexts[i];
-        if(termContext != null && termContext.docFreq() <= this.maxDocFreq) {
-          this.finalContexts.add(termContext);
-          this.finalTerms.add(queryTerms[i]);
-        }
-      }
-
       return this;
     }
 
@@ -211,6 +196,20 @@ public class GraphTermsQParserPlugin extends QParserPlugin {
 
     @Override
     public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException
{
+
+      List<TermContext> finalContexts = new ArrayList();
+      List<Term> finalTerms = new ArrayList();
+      List<LeafReaderContext> contexts = searcher.getTopReaderContext().leaves();
+      TermContext[] termContexts = new TermContext[this.queryTerms.length];
+      collectTermContext(searcher.getIndexReader(), contexts, termContexts, this.queryTerms);
+      for(int i=0; i<termContexts.length; i++) {
+        TermContext termContext = termContexts[i];
+        if(termContext != null && termContext.docFreq() <= this.maxDocFreq) {
+          finalContexts.add(termContext);
+          finalTerms.add(queryTerms[i]);
+        }
+      }
+
       return new ConstantScoreWeight(this) {
 
         @Override


Mime
View raw message