本文整理汇总了C#中Mono.Lucene.Net.Index.IndexReader.Terms方法的典型用法代码示例。如果您正苦于以下问题:C# Mono.Lucene.Net.Index.IndexReader.Terms方法的具体用法?C# Mono.Lucene.Net.Index.IndexReader.Terms怎么用?C# Mono.Lucene.Net.Index.IndexReader.Terms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Lucene.Net.Index.IndexReader
的用法示例。
在下文中一共展示了Mono.Lucene.Net.Index.IndexReader.Terms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WildcardTermEnum
/// <summary> Creates a new <code>WildcardTermEnum</code>.
/// <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: FuzzyTermEnum
/// <summary> Constructor for enumeration of all terms from specified <code>reader</code> which share a prefix of
/// length <code>prefixLength</code> with <code>term</code> and which have a fuzzy similarity >
/// <code>minSimilarity</code>.
/// <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));
InitializeMaxDistances();
this.d = InitDistanceArray();
SetEnum(reader.Terms(new Term(searchTerm.Field(), prefix)));
}
示例3: TermRangeTermEnum
/// <summary> Enumerates all terms greater/equal than <code>lowerTerm</code>
/// but less/equal than <code>upperTerm</code>.
///
/// 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 <code>lowerTerm</code> is included in the range.
/// </param>
/// <param name="includeUpper">If true, the <code>upperTerm</code> 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 <code>lowerTerm</code> and
/// <code>upperTerm</code>.
///
/// </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: CreateValue
protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
{
System.String field = StringHelper.Intern((System.String) 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;
}
示例5: DetectFieldType
internal static int DetectFieldType(IndexReader reader, System.String fieldKey)
{
System.String field = StringHelper.Intern(fieldKey);
TermEnum enumerator = reader.Terms(new Term(field));
try
{
Term term = enumerator.Term();
if (term == null)
{
throw new System.SystemException("no terms in field " + field + " - cannot determine sort type");
}
int ret = 0;
if ((System.Object) term.Field() == (System.Object) field)
{
System.String termtext = term.Text().Trim();
int tmpI32; long tmpI64; float tmpF;
if (System.Int32.TryParse(termtext, out tmpI32)) ret = SortField.INT;
else if (System.Int64.TryParse(termtext, out tmpI64)) ret = SortField.LONG;
else if (SupportClass.Single.TryParse(termtext, out tmpF)) ret = SortField.FLOAT;
else ret = SortField.STRING;
}
else
{
throw new System.SystemException("field \"" + field + "\" does not appear to be indexed");
}
return ret;
}
finally
{
enumerator.Close();
}
}