SOLR-1900: fix MultiFields/DocsEnum usage

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@951518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-06-04 18:26:29 +00:00
parent 89cda5401c
commit 6ffc159b40
1 changed files with 4 additions and 5 deletions

View File

@ -24,7 +24,6 @@ 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;
@ -478,13 +477,13 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean {
*/
public int getFirstMatch(Term t) throws IOException {
Fields fields = MultiFields.getFields(reader);
if (fields == null) return -1;
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);
BytesRef termBytes = new BytesRef(t.text());
DocsEnum docs = terms.docs(MultiFields.getDeletedDocs(reader), termBytes, null);
if (docs == null) return -1;
int id = docs.docID();
int id = docs.nextDoc();
return id == DocIdSetIterator.NO_MORE_DOCS ? -1 : id;
}