本文整理汇总了Java中org.apache.lucene.index.TermDocs类的典型用法代码示例。如果您正苦于以下问题:Java TermDocs类的具体用法?Java TermDocs怎么用?Java TermDocs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TermDocs类属于org.apache.lucene.index包,在下文中一共展示了TermDocs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: locateContainer
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
protected boolean locateContainer(String nodeRef, IndexReader reader)
{
boolean found = false;
try
{
TermDocs td = reader.termDocs(new Term("ID", nodeRef));
while (td.next())
{
int doc = td.doc();
Document document = reader.document(doc);
if (document.getField("ISCONTAINER") != null)
{
found = true;
break;
}
}
td.close();
}
catch (IOException e)
{
throw new LuceneIndexException("Failed to delete container and below for " + nodeRef, e);
}
return found;
}
示例2: getDocIdSet
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException
{
int max = reader.maxDoc();
OpenBitSet good = new OpenBitSet(max);
good.set(0, max);
for( List<Field> values : terms )
{
for( Field nv : values )
{
Term term = new Term(nv.getField(), nv.getValue());
TermDocs docs = reader.termDocs(term);
while( docs.next() )
{
good.clear(docs.doc());
}
docs.close();
}
}
return good;
}
示例3: indexGet
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
private String indexGet(final String key) throws IOException {
final Term s = new Term(KEY_FIELD, key);
synchronized (this.luceneWriter) {
for (int attempt = 0;; ++attempt) {
try {
final TermDocs termDocs = this.luceneReader.termDocs(s);
if (termDocs.next()) {
final Document doc = this.luceneReader.document(termDocs.doc());
return doc.get(VALUE_FIELD);
}
return null;
} catch (final Throwable ex) {
indexError(ex, attempt);
}
}
}
}
示例4: main
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
public static void main(String[] args) {
String indexPath = args[0];
String url = args[1];
try {
IndexReader reader = IndexReader.open(FSDirectory.open(new File(indexPath)), false);
Term s = new Term(LuceneDataStore.LuceneTransaction.KEY_NAME, url);
TermDocs termDocs = reader.termDocs(s);
if (termDocs.next()) {
Document document = reader.document(termDocs.doc());
// Record r = LuceneDataStore.unserializeRecord(document.getBinaryValue(LuceneDataStore.LuceneTransaction.VALUE_NAME));
// System.out.println(r.toString(null, true));
}
else {
logger.info("URI {} not found", url);
}
reader.close();
} catch (Exception e) {
logger.error(e.getMessage());
}
}
示例5: filter
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
public boolean filter(Term t)
{
int freq = 0;
TermDocs tDocs;
try {
tDocs = indexReader.termDocs(t);
while( tDocs.next() ){
freq += tDocs.freq();
}
if( freq < minFreq ){
return false;
}
}
catch(Exception e)
{
e.printStackTrace();
}
return true;
}
示例6: getLargestTxIdByCommitTime
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
private long getLargestTxIdByCommitTime(SolrIndexReader reader, Long lastTxCommitTimeBeforeHoles)
throws IOException
{
long txid = -1;
if (lastTxCommitTimeBeforeHoles != -1)
{
TermDocs docs = reader.termDocs(new Term(QueryConstants.FIELD_TXCOMMITTIME, NumericEncoder
.encode(lastTxCommitTimeBeforeHoles)));
while (docs.next())
{
Document doc = reader.document(docs.doc());
Fieldable field = doc.getFieldable(QueryConstants.FIELD_TXID);
if (field != null)
{
long currentTxId = Long.valueOf(field.stringValue());
if (currentTxId > txid)
{
txid = currentTxId;
}
}
}
}
return txid;
}
示例7: getLargestChangeSetIdByCommitTime
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
private long getLargestChangeSetIdByCommitTime(SolrIndexReader reader, Long lastChangeSetCommitTimeBeforeHoles)
throws IOException
{
long txid = -1;
if (lastChangeSetCommitTimeBeforeHoles != -1)
{
TermDocs docs = reader.termDocs(new Term(QueryConstants.FIELD_ACLTXCOMMITTIME, NumericEncoder
.encode(lastChangeSetCommitTimeBeforeHoles)));
while (docs.next())
{
Document doc = reader.document(docs.doc());
Fieldable field = doc.getFieldable(QueryConstants.FIELD_ACLTXID);
if (field != null)
{
long currentTxId = Long.valueOf(field.stringValue());
if (currentTxId > txid)
{
txid = currentTxId;
}
}
}
}
return txid;
}
示例8: queryFieldByUuid
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
/**
* Returns the field values associated with a document
* @param context the operation context
* @param fieldName the field name
* @param uuid the document uuid
* @return the field values (null if not found)
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if an I/O exception occurs
*/
public String[] queryFieldByUuid(TocContext context, String fieldName, String uuid)
throws CorruptIndexException, IOException {
TermDocs termDocs = null;
try {
uuid = Val.chkStr(uuid);
if (uuid.length() > 0) {
IndexSearcher searcher = this.getSearcher(context);
IndexReader reader = searcher.getIndexReader();
MapFieldSelector selector = new MapFieldSelector(new String[]{fieldName});
termDocs = reader.termDocs();
termDocs.seek(new Term(Storeables.FIELD_UUID,uuid));
if (termDocs.next()) {
Document document = reader.document(termDocs.doc(),selector);
return document.getValues(fieldName);
}
}
} finally {
try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
}
return null;
}
示例9: queryValues
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
/**
* Queries for documents that match one or more of the supplied values.
* @param reader the index reader
* @return the OpenBitSet (documents with matches are set to true)
* @throws IOException if an exception is encountered while reading the index
*/
private OpenBitSet queryValues(IndexReader reader, String field, String[] values) throws IOException {
OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
if ((values != null) && (values.length > 0)) {
TermDocs termDocs = null;
try {
Term baseTerm = new Term(field);
termDocs = reader.termDocs();
for (String value: values) {
termDocs.seek(baseTerm.createTerm(value.trim().toLowerCase()));
while (termDocs.next()) {
bitSet.set(termDocs.doc());
}
}
} finally {
try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
}
}
return bitSet;
}
示例10: queryValue
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
/**
* Queries for documents that match the supplied value.
* @param reader the index reader
* @return the OpenBitSet (documents with matches are set to true)
* @throws IOException if an exception is encountered while reading the index
*/
private OpenBitSet queryValue(IndexReader reader, String field, String value) throws IOException {
OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
if ((value != null) && (value.length() > 0)) {
TermDocs termDocs = null;
try {
Term term = new Term(field,value);
termDocs = reader.termDocs();
termDocs.seek(term);
while (termDocs.next()) {
bitSet.set(termDocs.doc());
}
} finally {
try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
}
}
return bitSet;
}
示例11: queryValue
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
/**
* Queries for documents that match the supplied value.
* @param reader the index reader
* @return the OpenBitSet (documents with matches are set to true)
* @throws IOException if an exception is encountered while reading the index
*/
private OpenBitSet queryValue(IndexReader reader) throws IOException {
OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
if ((this.value != null) && (this.value.length() > 0)) {
TermDocs termDocs = null;
try {
Term term = new Term(this.fieldName,this.value);
termDocs = reader.termDocs();
termDocs.seek(term);
while (termDocs.next()) {
bitSet.set(termDocs.doc());
}
} finally {
try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
}
}
return bitSet;
}
示例12: scorer
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
final Scorer scorer(IndexReader reader) throws IOException {
if (terms.size() == 0) // optimize zero-term case
return null;
if (terms.size() == 1) { // optimize one-term case
Term term = (Term)terms.elementAt(0);
TermDocs docs = reader.termDocs(term);
if (docs == null)
return null;
return new TermScorer(docs, reader.norms(term.field()), weight);
}
TermPositions[] tps = new TermPositions[terms.size()];
for (int i = 0; i < terms.size(); i++) {
TermPositions p = reader.termPositions((Term)terms.elementAt(i));
if (p == null)
return null;
tps[i] = p;
}
if (slop == 0) // optimize exact case
return new ExactPhraseScorer(tps, reader.norms(field), weight);
else
return
new SloppyPhraseScorer(tps, slop, reader.norms(field), weight);
}
示例13: deletePrimary
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
protected static Set<String> deletePrimary(Collection<String> nodeRefs, IndexReader reader, boolean delete)
throws LuceneIndexException
{
Set<String> refs = new LinkedHashSet<String>();
for (String nodeRef : nodeRefs)
{
try
{
TermDocs td = reader.termDocs(new Term("PRIMARYPARENT", nodeRef));
while (td.next())
{
int doc = td.doc();
Document document = reader.document(doc);
String[] ids = document.getValues("ID");
refs.add(ids[ids.length - 1]);
if (delete)
{
reader.deleteDocument(doc);
}
}
td.close();
}
catch (IOException e)
{
throw new LuceneIndexException("Failed to delete node by primary parent for " + nodeRef, e);
}
}
return refs;
}
示例14: deleteReference
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
protected static Set<String> deleteReference(Collection<String> nodeRefs, IndexReader reader, boolean delete)
throws LuceneIndexException
{
Set<String> refs = new LinkedHashSet<String>();
for (String nodeRef : nodeRefs)
{
try
{
TermDocs td = reader.termDocs(new Term("PARENT", nodeRef));
while (td.next())
{
int doc = td.doc();
Document document = reader.document(doc);
String[] ids = document.getValues("ID");
refs.add(ids[ids.length - 1]);
if (delete)
{
reader.deleteDocument(doc);
}
}
td.close();
}
catch (IOException e)
{
throw new LuceneIndexException("Failed to delete node by parent for " + nodeRef, e);
}
}
return refs;
}
示例15: deleteContainerAndBelow
import org.apache.lucene.index.TermDocs; //导入依赖的package包/类
protected static Set<String> deleteContainerAndBelow(String nodeRef, IndexReader reader, boolean delete,
boolean cascade) throws LuceneIndexException
{
Set<String> refs = new LinkedHashSet<String>();
try
{
if (delete)
{
reader.deleteDocuments(new Term("ID", nodeRef));
}
refs.add(nodeRef);
if (cascade)
{
TermDocs td = reader.termDocs(new Term("ANCESTOR", nodeRef));
while (td.next())
{
int doc = td.doc();
Document document = reader.document(doc);
String[] ids = document.getValues("ID");
refs.add(ids[ids.length - 1]);
if (delete)
{
reader.deleteDocument(doc);
}
}
td.close();
}
}
catch (IOException e)
{
throw new LuceneIndexException("Failed to delete container and below for " + nodeRef, e);
}
return refs;
}