本文整理汇总了C#中Transformalize.Libs.Lucene.Net.Index.IndexReader.Terms方法的典型用法代码示例。如果您正苦于以下问题:C# IndexReader.Terms方法的具体用法?C# IndexReader.Terms怎么用?C# IndexReader.Terms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transformalize.Libs.Lucene.Net.Index.IndexReader
的用法示例。
在下文中一共展示了IndexReader.Terms方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WildcardTermEnum
/// <summary> Creates a new <c>WildcardTermEnum</c>.
/// <p/>
/// After calling the constructor the enumeration is already pointing to the first
/// valid term if such a term exists.
/// </summary>
public WildcardTermEnum(IndexReader reader, Term term):base()
{
searchTerm = term;
field = searchTerm.Field;
System.String searchTermText = searchTerm.Text;
int sidx = searchTermText.IndexOf((System.Char) WILDCARD_STRING);
int cidx = searchTermText.IndexOf((System.Char) WILDCARD_CHAR);
int idx = sidx;
if (idx == - 1)
{
idx = cidx;
}
else if (cidx >= 0)
{
idx = System.Math.Min(idx, cidx);
}
pre = idx != - 1?searchTerm.Text.Substring(0, (idx) - (0)):"";
preLen = pre.Length;
text = searchTermText.Substring(preLen);
SetEnum(reader.Terms(new Term(searchTerm.Field, pre)));
}
示例2: CreateValue
protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
{
System.String field = StringHelper.Intern(entryKey.field);
int[] retArray = new int[reader.MaxDoc];
System.String[] mterms = new System.String[reader.MaxDoc + 1];
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
{
do
{
Term term = termEnum.Term;
if (term == null || term.Field != field || t >= mterms.Length) break;
// store term text
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);
return value_Renamed;
}
示例3: TermRangeTermEnum
/// <summary> Enumerates all terms greater/equal than <c>lowerTerm</c>
/// but less/equal than <c>upperTerm</c>.
///
/// If an endpoint is null, it is said to be "open". Either or both
/// endpoints may be open. Open endpoints may not be exclusive
/// (you can't select all but the first or last term without
/// explicitly specifying the term to exclude.)
///
/// </summary>
/// <param name="reader">
/// </param>
/// <param name="field">An interned field that holds both lower and upper terms.
/// </param>
/// <param name="lowerTermText">The term text at the lower end of the range
/// </param>
/// <param name="upperTermText">The term text at the upper end of the range
/// </param>
/// <param name="includeLower">If true, the <c>lowerTerm</c> is included in the range.
/// </param>
/// <param name="includeUpper">If true, the <c>upperTerm</c> is included in the range.
/// </param>
/// <param name="collator">The collator to use to collate index Terms, to determine their
/// membership in the range bounded by <c>lowerTerm</c> and
/// <c>upperTerm</c>.
///
/// </param>
/// <throws> IOException </throws>
public TermRangeTermEnum(IndexReader reader, System.String field, System.String lowerTermText, System.String upperTermText, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator)
{
this.collator = collator;
this.upperTermText = upperTermText;
this.lowerTermText = lowerTermText;
this.includeLower = includeLower;
this.includeUpper = includeUpper;
this.field = StringHelper.Intern(field);
// do a little bit of normalization...
// open ended range queries should always be inclusive.
if (this.lowerTermText == null)
{
this.lowerTermText = "";
this.includeLower = true;
}
if (this.upperTermText == null)
{
this.includeUpper = true;
}
System.String startTermText = collator == null?this.lowerTermText:"";
SetEnum(reader.Terms(new Term(this.field, startTermText)));
}
示例4: PrefixTermEnum
public PrefixTermEnum(IndexReader reader, Term prefix)
{
this.prefix = prefix;
SetEnum(reader.Terms(new Term(prefix.Field, prefix.Text)));
}
示例5: FuzzyTermEnum
/// <summary> Constructor for enumeration of all terms from specified <c>reader</c> which share a prefix of
/// length <c>prefixLength</c> with <c>term</c> and which have a fuzzy similarity >
/// <c>minSimilarity</c>.
/// <p/>
/// After calling the constructor the enumeration is already pointing to the first
/// valid term if such a term exists.
///
/// </summary>
/// <param name="reader">Delivers terms.
/// </param>
/// <param name="term">Pattern term.
/// </param>
/// <param name="minSimilarity">Minimum required similarity for terms from the reader. Default value is 0.5f.
/// </param>
/// <param name="prefixLength">Length of required common prefix. Default value is 0.
/// </param>
/// <throws> IOException </throws>
public FuzzyTermEnum(IndexReader reader, Term term, float minSimilarity, int prefixLength):base()
{
if (minSimilarity >= 1.0f)
throw new System.ArgumentException("minimumSimilarity cannot be greater than or equal to 1");
else if (minSimilarity < 0.0f)
throw new System.ArgumentException("minimumSimilarity cannot be less than 0");
if (prefixLength < 0)
throw new System.ArgumentException("prefixLength cannot be less than 0");
this.minimumSimilarity = minSimilarity;
this.scale_factor = 1.0f / (1.0f - minimumSimilarity);
this.searchTerm = term;
this.field = searchTerm.Field;
//The prefix could be longer than the word.
//It's kind of silly though. It means we must match the entire word.
int fullSearchTermLength = searchTerm.Text.Length;
int realPrefixLength = prefixLength > fullSearchTermLength?fullSearchTermLength:prefixLength;
this.text = searchTerm.Text.Substring(realPrefixLength);
this.prefix = searchTerm.Text.Substring(0, (realPrefixLength) - (0));
this.p = new int[this.text.Length + 1];
this.d = new int[this.text.Length + 1];
SetEnum(reader.Terms(new Term(searchTerm.Field, prefix)));
}
示例6: SingleTermEnum
/// <summary>
/// Creates a new <c>SingleTermEnum</c>.
/// <p/>
/// After calling the constructor the enumeration is already pointing to the term,
/// if it exists.
/// </summary>
public SingleTermEnum(IndexReader reader, Term singleTerm)
{
this.singleTerm = singleTerm;
SetEnum(reader.Terms(singleTerm));
}