You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2010/06/04 01:40:34 UTC
svn commit: r951209 -
/lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java
Author: yonik
Date: Thu Jun 3 23:40:34 2010
New Revision: 951209
URL: http://svn.apache.org/viewvc?rev=951209&view=rev
Log:
SOLR-1900: remove last use of TermDocs in SolrIndexSearcher
Modified:
lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=951209&r1=951208&r2=951209&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java Thu Jun 3 23:40:34 2010
@@ -24,6 +24,7 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.UnicodeUtil;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.SolrConfig;
@@ -476,14 +477,15 @@ public class SolrIndexSearcher extends I
* @return the first document number containing the term
*/
public int getFirstMatch(Term t) throws IOException {
- TermDocs tdocs = null;
- try {
- tdocs = reader.termDocs(t);
- if (!tdocs.next()) return -1;
- return tdocs.doc();
- } finally {
- if (tdocs!=null) tdocs.close();
- }
+ Fields fields = MultiFields.getFields(reader);
+ Terms terms = fields.terms(t.field());
+ if (terms == null) return -1;
+ BytesRef termBytes = new BytesRef();
+ UnicodeUtil.UTF16toUTF8(t.text(), 0, t.text().length(), termBytes);
+ DocsEnum docs = terms.docs(reader.getDeletedDocs(), termBytes, null);
+ if (docs == null) return -1;
+ int id = docs.docID();
+ return id == DocIdSetIterator.NO_MORE_DOCS ? -1 : id;
}