本文整理汇总了C#中Lucene.Net.Index.IndexReader.TermDocs方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Index.IndexReader.TermDocs方法的具体用法?C# Lucene.Net.Index.IndexReader.TermDocs怎么用?C# Lucene.Net.Index.IndexReader.TermDocs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.IndexReader
的用法示例。
在下文中一共展示了Lucene.Net.Index.IndexReader.TermDocs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchAllScorer
internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w, byte[] norms):base(similarity)
{
InitBlock(enclosingInstance);
this.termDocs = reader.TermDocs(null);
score = w.GetValue();
this.norms = norms;
}
示例2: CreateValue
protected internal override System.Object CreateValue(IndexReader reader, System.Object entryKey)
{
Entry entry = (Entry) entryKey;
System.String field = entry.field;
LongParser parser = (LongParser) entry.custom;
long[] retArray = new long[reader.MaxDoc()];
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field, ""));
try
{
do
{
Term term = termEnum.Term();
if (term == null || (System.Object) term.Field() != (System.Object) field)
break;
long termval = parser.ParseLong(term.Text());
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
finally
{
termDocs.Close();
termEnum.Close();
}
return retArray;
}
示例3: ValueSourceScorer
// constructor
internal ValueSourceScorer(ValueSourceQuery enclosingInstance, Similarity similarity, IndexReader reader, ValueSourceWeight w):base(similarity)
{
InitBlock(enclosingInstance);
this.weight = w;
this.qWeight = w.GetValue();
// this is when/where the values are first created.
vals = Enclosing_Instance.valSrc.GetValues(reader);
termDocs = reader.TermDocs(null);
}
示例4: CreateValue
protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
{
Entry entry = (Entry) entryKey;
System.String field = entry.field;
FloatParser parser = (FloatParser) entry.custom;
if (parser == null)
{
try
{
return wrapper.GetFloats(reader, field, Lucene.Net.Search.FieldCache_Fields.DEFAULT_FLOAT_PARSER);
}
catch (System.FormatException ne)
{
return wrapper.GetFloats(reader, field, Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_FLOAT_PARSER);
}
}
float[] retArray = null;
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field));
try
{
do
{
Term term = termEnum.Term();
if (term == null || (System.Object) term.Field() != (System.Object) field)
break;
float termval = parser.ParseFloat(term.Text());
if (retArray == null)
// late init
retArray = new float[reader.MaxDoc()];
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
catch (StopFillCacheException stop)
{
}
finally
{
termDocs.Close();
termEnum.Close();
}
if (retArray == null)
// no values
retArray = new float[reader.MaxDoc()];
return retArray;
}
示例5: Generate
public virtual void Generate(IndexReader reader)
{
TermEnum enumerator = reader.Terms(prefix);
TermDocs termDocs = reader.TermDocs();
try
{
System.String prefixText = prefix.Text();
System.String prefixField = prefix.Field();
do
{
Term term = enumerator.Term();
if (term != null && term.Text().StartsWith(prefixText) && (System.Object) term.Field() == (System.Object) prefixField)
{
termDocs.Seek(term);
while (termDocs.Next())
{
HandleDoc(termDocs.Doc());
}
}
else
{
break;
}
}
while (enumerator.Next());
}
finally
{
termDocs.Close();
enumerator.Close();
}
}
示例6: GetInts
// inherit javadocs
public virtual int[] GetInts(IndexReader reader, System.String field, IntParser parser)
{
field = String.Intern(field);
System.Object ret = Lookup(reader, field, parser);
if (ret == null)
{
int[] retArray = new int[reader.MaxDoc()];
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field, ""));
try
{
do
{
Term term = termEnum.Term();
if (term == null || term.Field() != field)
break;
int termval = parser.ParseInt(term.Text());
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
finally
{
termDocs.Close();
termEnum.Close();
}
Store(reader, field, parser, retArray);
return retArray;
}
return (int[]) ret;
}
示例7: Explain
public override Explanation Explain(IndexReader reader, int doc)
{
ComplexExplanation result = new ComplexExplanation();
result.Description = "weight(" + Query + " in " + doc + "), product of:";
Explanation expl = new Explanation(idf, idfExp.Explain());
// explain query weight
Explanation queryExpl = new Explanation();
queryExpl.Description = "queryWeight(" + Query + "), product of:";
Explanation boostExpl = new Explanation(Enclosing_Instance.Boost, "boost");
if (Enclosing_Instance.Boost != 1.0f)
queryExpl.AddDetail(boostExpl);
queryExpl.AddDetail(expl);
Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
queryExpl.AddDetail(queryNormExpl);
queryExpl.Value = boostExpl.Value * expl.Value * queryNormExpl.Value;
result.AddDetail(queryExpl);
// explain field weight
System.String field = Enclosing_Instance.term.Field;
ComplexExplanation fieldExpl = new ComplexExplanation();
fieldExpl.Description = "fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:";
Explanation tfExplanation = new Explanation();
int tf = 0;
TermDocs termDocs = reader.TermDocs(enclosingInstance.term);
if (termDocs != null)
{
try
{
if (termDocs.SkipTo(doc) && termDocs.Doc == doc)
{
tf = termDocs.Freq;
}
}
finally
{
termDocs.Close();
}
tfExplanation.Value = similarity.Tf(tf);
tfExplanation.Description = "tf(termFreq(" + enclosingInstance.term + ")=" + tf + ")";
}
else
{
tfExplanation.Value = 0.0f;
tfExplanation.Description = "no matching term";
}
fieldExpl.AddDetail(tfExplanation);
fieldExpl.AddDetail(expl);
Explanation fieldNormExpl = new Explanation();
byte[] fieldNorms = reader.Norms(field);
float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
fieldNormExpl.Value = fieldNorm;
fieldNormExpl.Description = "fieldNorm(field=" + field + ", doc=" + doc + ")";
fieldExpl.AddDetail(fieldNormExpl);
fieldExpl.Match = tfExplanation.IsMatch;
fieldExpl.Value = tfExplanation.Value * expl.Value * fieldNormExpl.Value;
result.AddDetail(fieldExpl);
System.Boolean? tempAux = fieldExpl.Match;
result.Match = tempAux;
// combine them
result.Value = queryExpl.Value * fieldExpl.Value;
if (queryExpl.Value == 1.0f)
return fieldExpl;
return result;
}
示例8: GetFloats
// inherit javadocs
public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
{
field = String.Intern(field);
System.Object ret = Lookup(reader, field, parser);
if (ret == null)
{
float[] retArray = new float[reader.MaxDoc()];
if (retArray.Length > 0)
{
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field, ""));
try
{
if (termEnum.Term() == null)
{
throw new System.SystemException("no terms in field " + field);
}
do
{
Term term = termEnum.Term();
if (term.Field() != field)
break;
float termval;
try
{
termval = SupportClass.Single.Parse(term.Text());
}
catch (Exception e)
{
termval = 0;
}
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
finally
{
termDocs.Close();
termEnum.Close();
}
}
Store(reader, field, parser, retArray);
return retArray;
}
return (float[]) ret;
}
示例9: CreateValue
protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
{
Entry entry = (Entry) entryKey;
System.String field = entry.field;
ByteParser parser = (ByteParser) entry.custom;
if (parser == null)
{
return wrapper.GetBytes(reader, field, Lucene.Net.Search.FieldCache_Fields.DEFAULT_BYTE_PARSER);
}
byte[] retArray = new byte[reader.MaxDoc()];
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field));
try
{
do
{
Term term = termEnum.Term();
if (term == null || (System.Object) term.Field() != (System.Object) field)
break;
byte termval = parser.ParseByte(term.Text());
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
catch (StopFillCacheException stop)
{
}
finally
{
termDocs.Close();
termEnum.Close();
}
return retArray;
}
示例10: Scorer
public virtual Scorer Scorer(IndexReader reader)
{
TermDocs termDocs = reader.TermDocs(Enclosing_Instance.term);
if (termDocs == null)
return null;
return new TermScorer(this, termDocs, similarity, reader.Norms(Enclosing_Instance.term.Field()));
}
示例11: Bits
/// <summary> Returns a BitSet with true for documents which should be
/// permitted in search results, and false for those that should
/// not.
/// </summary>
public override System.Collections.BitArray Bits(IndexReader reader)
{
System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
TermEnum enumerator = reader.Terms(new Term(field, start));
TermDocs termDocs = reader.TermDocs();
if (enumerator.Term() == null)
{
return bits;
}
try
{
Term stop = new Term(field, end);
while (enumerator.Term().CompareTo(stop) <= 0)
{
termDocs.Seek(enumerator.Term());
while (termDocs.Next())
{
bits.Set(termDocs.Doc(), true);
}
if (!enumerator.Next())
{
break;
}
}
}
finally
{
enumerator.Close();
termDocs.Close();
}
return bits;
}
示例12: Generate
public virtual void Generate(MultiTermQuery query, IndexReader reader, TermEnum enumerator)
{
int[] docs = new int[32];
int[] freqs = new int[32];
TermDocs termDocs = reader.TermDocs();
try
{
int termCount = 0;
do
{
Term term = enumerator.Term();
if (term == null)
break;
termCount++;
termDocs.Seek(term);
while (true)
{
int count = termDocs.Read(docs, freqs);
if (count != 0)
{
for (int i = 0; i < count; i++)
{
HandleDoc(docs[i]);
}
}
else
{
break;
}
}
}
while (enumerator.Next());
query.IncTotalNumberOfTerms(termCount); // {{Aroush-2.9}} is the use of 'temp' as is right?
}
finally
{
termDocs.Close();
}
}
示例13: CreateValue
protected internal override object CreateValue(IndexReader reader, object fieldKey)
{
System.String field = String.Intern(((System.String) fieldKey));
System.String[] retArray = new System.String[reader.MaxDoc()];
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field));
try
{
do
{
Term term = termEnum.Term();
if (term == null || (object) term.Field() != (object) field)
break;
System.String termval = term.Text();
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
finally
{
termDocs.Close();
termEnum.Close();
}
return retArray;
}
示例14: GetCustom
// inherit javadocs
public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator)
{
field = String.Intern(field);
System.Object ret = Lookup(reader, field, comparator);
if (ret == null)
{
System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
if (retArray.Length > 0)
{
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field, ""));
try
{
if (termEnum.Term() == null)
{
throw new System.SystemException("no terms in field " + field);
}
do
{
Term term = termEnum.Term();
if (term.Field() != field)
break;
System.IComparable termval = comparator.GetComparable(term.Text());
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
finally
{
termDocs.Close();
termEnum.Close();
}
}
Store(reader, field, comparator, retArray);
return retArray;
}
return (System.IComparable[]) ret;
}
示例15: GetStringIndex
// inherit javadocs
public virtual StringIndex GetStringIndex(IndexReader reader, System.String field)
{
field = String.Intern(field);
System.Object ret = Lookup(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX);
if (ret == null)
{
int[] retArray = new int[reader.MaxDoc()];
System.String[] mterms = new System.String[reader.MaxDoc() + 1];
if (retArray.Length > 0)
{
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field, ""));
int t = 0; // current term number
// an entry for documents that have no terms in this field
// should a document with no terms be at top or bottom?
// this puts them at the top - if it is changed, FieldDocSortedHitQueue
// needs to change as well.
mterms[t++] = null;
try
{
if (termEnum.Term() == null)
{
throw new System.SystemException("no terms in field " + field);
}
do
{
Term term = termEnum.Term();
if (term.Field() != field)
break;
// store term text
// we expect that there is at most one term per document
if (t >= mterms.Length)
throw new System.SystemException("there are more terms than " + "documents in field \"" + field + "\", but it's impossible to sort on " + "tokenized fields");
mterms[t] = term.Text();
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = t;
}
t++;
}
while (termEnum.Next());
}
finally
{
termDocs.Close();
termEnum.Close();
}
if (t == 0)
{
// if there are no terms, make the term array
// have a single null entry
mterms = new System.String[1];
}
else if (t < mterms.Length)
{
// if there are less terms than documents,
// trim off the dead array space
System.String[] terms = new System.String[t];
Array.Copy(mterms, 0, terms, 0, t);
mterms = terms;
}
}
StringIndex value_Renamed = new StringIndex(retArray, mterms);
Store(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX, value_Renamed);
return value_Renamed;
}
return (StringIndex) ret;
}