本文整理汇总了C#中Lucene.Net.Index.Term类的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Index.Term类的具体用法?C# Lucene.Net.Index.Term怎么用?C# Lucene.Net.Index.Term使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lucene.Net.Index.Term类属于命名空间,在下文中一共展示了Lucene.Net.Index.Term类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(System.String[] args)
{
System.String usage = typeof(DeleteFiles) + " <unique_term>";
if (args.Length == 0)
{
System.Console.Error.WriteLine("Usage: " + usage);
System.Environment.Exit(1);
}
try
{
Directory directory = FSDirectory.Open("index");
IndexReader reader = IndexReader.Open(directory, false); // we don't want read-only because we are about to delete
Term term = new Term("path", args[0]);
int deleted = reader.DeleteDocuments(term);
System.Console.Out.WriteLine("deleted " + deleted + " documents containing " + term);
// one can also delete documents by their internal id:
/*
for (int i = 0; i < reader.maxDoc(); i++) {
System.out.println("Deleting document with id " + i);
reader.delete(i);
}*/
reader.Close();
directory.Close();
}
catch (System.Exception e)
{
System.Console.Out.WriteLine(" caught a " + e.GetType() + "\n with message: " + e.Message);
}
}
示例2: Read
public void Read(IndexInput input, FieldInfos fieldInfos)
{
this.Term = null; // invalidate cache
NewSuffixStart = input.ReadVInt();
int length = input.ReadVInt();
int totalLength = NewSuffixStart + length;
Debug.Assert(totalLength <= ByteBlockPool.BYTE_BLOCK_SIZE - 2, "termLength=" + totalLength + ",resource=" + input);
if (Bytes.Bytes.Length < totalLength)
{
Bytes.Grow(totalLength);
}
Bytes.Length = totalLength;
input.ReadBytes(Bytes.Bytes, NewSuffixStart, length);
int fieldNumber = input.ReadVInt();
if (fieldNumber != CurrentFieldNumber)
{
CurrentFieldNumber = fieldNumber;
// NOTE: too much sneakiness here, seriously this is a negative vint?!
if (CurrentFieldNumber == -1)
{
Field = "";
}
else
{
Debug.Assert(fieldInfos.FieldInfo(CurrentFieldNumber) != null, CurrentFieldNumber.ToString());
Field = String.Intern(fieldInfos.FieldInfo(CurrentFieldNumber).Name);
}
}
else
{
Debug.Assert(Field.Equals(fieldInfos.FieldInfo(fieldNumber).Name), "currentFieldNumber=" + CurrentFieldNumber + " field=" + Field + " vs " + fieldInfos.FieldInfo(fieldNumber) == null ? "null" : fieldInfos.FieldInfo(fieldNumber).Name);
}
}
示例3: TermSpans
public TermSpans(TermPositions positions, Term term)
{
this.positions = positions;
this.term = term;
doc = - 1;
}
示例4: WildcardQuery
public WildcardQuery(Term term)
: base(term)
{
//will be removed in 3.0
this.term = term;
this.termContainsWildcard = (term.Text().IndexOf('*') != - 1) || (term.Text().IndexOf('?') != - 1);
}
示例5: Close
/// <summary>Closes the enumeration to further activity, freeing resources. </summary>
public override void Close()
{
if (actualEnum != null)
actualEnum.Close();
currentTerm = null;
actualEnum = null;
}
示例6: TermSpans
public TermSpans(TermPositions positions, Term term)
{
this.internalPositions = positions;
this.term = term;
internalDoc = - 1;
}
示例7: DocFreq
public override int DocFreq(Term term)
{
int docFreq = 0;
for (int i = 0; i < searchables.Length; i++)
docFreq += searchables[i].DocFreq(term);
return docFreq;
}
示例8: RegexTermEnum
public RegexTermEnum(IndexReader reader, Term term)
: base()
{
field = term.Field();
System.String text = term.Text();
pattern = new Pattern(text);
// Find the first regex character position, to find the
// maximum prefix to use for term enumeration
int index = 0;
while (index < text.Length)
{
char c = text[index];
if (!System.Char.IsLetterOrDigit(c))
break;
index++;
}
pre = text.Substring(0, (index) - (0));
SetEnum(reader.Terms(new Term(term.Field(), pre)));
}
示例9: CreateRandomTerms
public virtual void CreateRandomTerms(int nDocs, int nTerms, double power, Directory dir)
{
int[] freq = new int[nTerms];
for (int i = 0; i < nTerms; i++)
{
int f = (nTerms + 1) - i; // make first terms less frequent
freq[i] = (int) System.Math.Ceiling(System.Math.Pow(f, power));
terms[i] = new Term("f", System.Convert.ToString((char) ('A' + i)));
}
IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
for (int i = 0; i < nDocs; i++)
{
Document d = new Document();
for (int j = 0; j < nTerms; j++)
{
if (r.Next(freq[j]) == 0)
{
d.Add(new Field("f", terms[j].Text(), Field.Store.NO, Field.Index.UN_TOKENIZED));
//System.out.println(d);
}
}
iw.AddDocument(d);
}
iw.Optimize();
iw.Close();
}
示例10: DocFreq
/// <summary>
/// Executes each <see cref="Searchable"/>'s docFreq() in its own thread and
/// waits for each search to complete and merge the results back together.
/// </summary>
public override int DocFreq(Term term)
{
int[] results = new int[searchables.Length];
Parallel.For(0, searchables.Length, (i) => results[i] = searchables[i].DocFreq(term));
return results.Sum();
}
示例11: Add
/// <summary>Add multiple terms at the next position in the phrase. Any of the terms
/// may match.
///
/// </summary>
/// <seealso cref="PhraseQuery.Add(Term)">
/// </seealso>
public virtual void Add(Term[] terms)
{
int position = 0;
if (positions.Count > 0)
position = ((System.Int32) positions[positions.Count - 1]) + 1;
Add(terms, position);
}
示例12: Add
/// <summary> Adds a term to the end of the query phrase.
/// The relative position of the term is the one immediately after the last term added.
/// </summary>
public virtual void Add(Term term)
{
int position = 0;
if (positions.Count > 0)
position = positions[positions.Count - 1] + 1;
Add(term, position);
}
示例13: TermCompare
public /*protected internal*/ override bool TermCompare(Term term)
{
if ((System.Object) term.Field() == (System.Object) prefix.Field() && term.Text().StartsWith(prefix.Text()))
{
return true;
}
endEnum = true;
return false;
}
示例14: TermCompare
protected internal override bool TermCompare(Term term)
{
if ((System.Object) term.Field == (System.Object) prefix.Field && term.Text.StartsWith(prefix.Text))
{
return true;
}
endEnum = true;
return false;
}
示例15: DocFreqs
// inherit javadoc
public virtual int[] DocFreqs(Term[] terms)
{
int[] result = new int[terms.Length];
for (int i = 0; i < terms.Length; i++)
{
result[i] = DocFreq(terms[i]);
}
return result;
}