Example usage for org.apache.solr.search SolrIndexSearcher docFreq

List of usage examples for org.apache.solr.search SolrIndexSearcher docFreq

Introduction

In this page you can find the example usage for org.apache.solr.search SolrIndexSearcher docFreq.

Prototype

public final int docFreq(Term term) throws IOException 

Source Link

Usage

From source file:com.lucid.solr.sidecar.SidecarIndexReaderFactory.java

License:Apache License

private Document lookup(SolrIndexSearcher lookup, String id, BytesRef idRef, Set<String> fields)
        throws IOException {
    idRef.copyChars(id);//from  ww  w . ja va2s. com
    Term t = new Term("id", idRef);
    if (lookup.docFreq(t) == 0) {
        return null;
    }

    int docId = lookup.getFirstMatch(t);
    if (docId == -1) {
        return null;
    }
    Document doc = lookup.doc(docId, fields);
    if (doc == null) {
        return null;
    }
    doc.removeFields("id");
    return doc;
}