本文整理汇总了C#中Lucene.Net.Index.Term.Field方法的典型用法代码示例。如果您正苦于以下问题:C# Term.Field方法的具体用法?C# Term.Field怎么用?C# Term.Field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.Term
的用法示例。
在下文中一共展示了Term.Field方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegexTermEnum
public RegexTermEnum(IndexReader reader, Term term, IRegexCapabilities regexImpl)
{
_sField = term.Field();
string sText = term.Text();
_regexImpl = regexImpl;
_regexImpl.Compile(sText);
_sPre = _regexImpl.Prefix() ?? "";
SetEnum(reader.Terms(new Term(term.Field(), _sPre)));
}
示例2: TestSimpleSkip
public virtual void TestSimpleSkip()
{
RAMDirectory dir = new RAMDirectory();
IndexWriter writer = new IndexWriter(dir, new PayloadAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
Term term = new Term("test", "a");
for (int i = 0; i < 5000; i++)
{
Document d1 = new Document();
d1.Add(new Field(term.Field(), term.Text(), Field.Store.NO, Field.Index.ANALYZED));
writer.AddDocument(d1);
}
writer.Flush();
writer.Optimize();
writer.Close();
IndexReader reader = SegmentReader.GetOnlySegmentReader(dir);
SegmentTermPositions tp = (SegmentTermPositions) reader.TermPositions();
tp.freqStream_ForNUnit = new CountingStream(this, tp.freqStream_ForNUnit);
for (int i = 0; i < 2; i++)
{
counter = 0;
tp.Seek(term);
CheckSkipTo(tp, 14, 185); // no skips
CheckSkipTo(tp, 17, 190); // one skip on level 0
CheckSkipTo(tp, 287, 200); // one skip on level 1, two on level 0
// this test would fail if we had only one skip level,
// because than more bytes would be read from the freqStream
CheckSkipTo(tp, 4800, 250); // one skip on level 2
}
}
示例3: TermCompare
public override bool TermCompare(Term term)
{
prefix = base.GetPrefixTerm();
if ((System.Object)term.Field() == (System.Object)prefix.Field() && term.Text().Equals(prefix.Text()))
{
return true;
}
endEnum = true;
return false;
}
示例4: TermCompare
/// <summary>Equality compare on the term </summary>
public override bool TermCompare(Term term)
{
if (_sField == term.Field())
{
string sSearchText = term.Text();
if (sSearchText.StartsWith(_sPre)) return _regexImpl.Match(sSearchText);
} //eif
_bEndEnum = true;
return false;
}
示例5: TermFilter
/// <param name="term"> The term documents need to have in order to be a match for this filter. </param>
public TermFilter(Term term)
{
if (term == null)
{
throw new System.ArgumentException("Term must not be null");
}
else if (term.Field() == null)
{
throw new System.ArgumentException("Field must not be null");
}
this.term = term;
}
示例6: Count
public static int Count(Term t, IndexReader r)
{
int count = 0;
DocsEnum td = TestUtil.Docs(Random(), r, t.Field(), new BytesRef(t.Text()), MultiFields.GetLiveDocs(r), null, 0);
if (td != null)
{
while (td.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
{
td.DocID();
count++;
}
}
return count;
}
示例7: DocumentCount
/// <summary>
/// 得到指定Term的文档
/// </summary>
/// <param name="term"></param>
/// <returns></returns>
public IList<TermDoc> DocumentCount(Term term)
{
TermDocs docs = open.Reader.TermDocs(term);
List<TermDoc> list = new List<TermDoc>();
while (docs.Next()) {
TermDoc doc2 = new TermDoc();
doc2.Freq = docs.Freq();
doc2.Doc = docs.Doc();
doc2.Term = term;
doc2.Norm = GetNorm(open.Reader, term.Field(), doc2.Doc);
TermDoc item = doc2;
list.Add(item);
}
docs.Close();
return list;
}
示例8: FastBits
private OpenBitSet FastBits(IndexReader reader)
{
OpenBitSet bits = new OpenBitSet(reader.MaxDoc());
bits.Set(0, reader.MaxDoc()); //assume all are valid
Term startTerm = new Term(fieldName);
TermEnum te = reader.Terms(startTerm);
if (te != null)
{
Term currTerm = te.Term();
while ((currTerm != null) && (currTerm.Field() == startTerm.Field())) //term fieldnames are interned
{
if (te.DocFreq() > 1)
{
int lastDoc = -1;
//unset potential duplicates
TermDocs td = reader.TermDocs(currTerm);
td.Next();
if (keepMode == KM_USE_FIRST_OCCURRENCE)
{
td.Next();
}
do
{
lastDoc = td.Doc();
bits.Clear(lastDoc);
} while (td.Next());
if (keepMode == KM_USE_LAST_OCCURRENCE)
{
//restore the last bit
bits.Set(lastDoc);
}
}
if (!te.Next())
{
break;
}
currTerm = te.Term();
}
}
return bits;
}
示例9: CorrectBits
private OpenBitSet CorrectBits(IndexReader reader)
{
OpenBitSet bits = new OpenBitSet(reader.MaxDoc()); //assume all are INvalid
Term startTerm = new Term(fieldName);
TermEnum te = reader.Terms(startTerm);
if (te != null)
{
Term currTerm = te.Term();
while ((currTerm != null) && (currTerm.Field() == startTerm.Field())) //term fieldnames are interned
{
int lastDoc = -1;
//set non duplicates
TermDocs td = reader.TermDocs(currTerm);
if (td.Next())
{
if (keepMode == KM_USE_FIRST_OCCURRENCE)
{
bits.Set(td.Doc());
}
else
{
do
{
lastDoc = td.Doc();
} while (td.Next());
bits.Set(lastDoc);
}
}
if (!te.Next())
{
break;
}
currTerm = te.Term();
}
}
return bits;
}
示例10: Seek
public override void Seek(Term term)
{
IndexReader reader = ((IndexReader) Enclosing_Instance.fieldToReader[term.Field()]);
termDocs = reader != null?reader.TermPositions(term):null;
}
示例11: GetTermText
private string GetTermText(Term term)
{
var fieldName = term.Field();
var fieldText = term.Text();
if (fieldText == null)
return null;
var info = SenseNet.ContentRepository.Schema.ContentTypeManager.GetPerFieldIndexingInfo(fieldName);
if (info == null)
{
var c = fieldText.ToCharArray();
for (int i = 0; i < c.Length; i++)
if (c[i] < ' ')
c[i] = '.';
return new String(c);
}
var fieldHandler = info.IndexFieldHandler;
switch (fieldHandler.IndexFieldType)
{
case SenseNet.Search.Indexing.IndexFieldType.String:
return GetTermText(fieldText);
case SenseNet.Search.Indexing.IndexFieldType.Int:
return Convert.ToString(NumericUtils.PrefixCodedToInt(fieldText), CultureInfo.InvariantCulture);
case SenseNet.Search.Indexing.IndexFieldType.Long:
return Convert.ToString(NumericUtils.PrefixCodedToLong(fieldText), CultureInfo.InvariantCulture);
case SenseNet.Search.Indexing.IndexFieldType.Float:
return Convert.ToString(NumericUtils.PrefixCodedToFloat(fieldText), CultureInfo.InvariantCulture);
case SenseNet.Search.Indexing.IndexFieldType.Double:
return Convert.ToString(NumericUtils.PrefixCodedToDouble(fieldText), CultureInfo.InvariantCulture);
case SenseNet.Search.Indexing.IndexFieldType.DateTime:
var d = new DateTime(NumericUtils.PrefixCodedToLong(fieldText));
if (d.Hour == 0 && d.Minute == 0 && d.Second == 0)
return GetTermText(d.ToString("yyyy-MM-dd"));
if (d.Second == 0)
return GetTermText(d.ToString("yyyy-MM-dd HH:mm"));
return GetTermText(d.ToString("yyyy-MM-dd HH:mm:ss"));
default:
throw new NotImplementedException("Unknown IndexFieldType: " + fieldHandler.IndexFieldType);
}
}
示例12: Set
public void Set(Term term)
{
if (term == null)
{
Reset();
return ;
}
// copy text into the buffer
SetTextLength(term.Text().Length);
System.String sourceString = term.Text();
int sourceEnd = term.Text().Length;
for (int i = 0; i < sourceEnd; i++)
{
text[i] = (char) sourceString[i];
}
this.field = term.Field();
this.term = term;
}
示例13: ParallelTermEnum
public ParallelTermEnum(ParallelReader enclosingInstance, Term term)
{
InitBlock(enclosingInstance);
field = term.Field();
IndexReader reader = ((IndexReader) Enclosing_Instance.fieldToReader[field]);
if (reader != null)
termEnum = reader.Terms(term);
}
示例14: VerifyTermDocs
private void VerifyTermDocs(Directory dir, Term term, int numDocs)
{
IndexReader reader = DirectoryReader.Open(dir);
DocsEnum docsEnum = TestUtil.Docs(Random(), reader, term.Field(), term.Bytes(), null, null, DocsEnum.FLAG_NONE);
int count = 0;
while (docsEnum.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
{
count++;
}
Assert.AreEqual(numDocs, count);
reader.Dispose();
}
示例15: TestSimpleSkip
public virtual void TestSimpleSkip()
{
Directory dir = new CountingRAMDirectory(this, new RAMDirectory());
IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new PayloadAnalyzer()).SetCodec(TestUtil.AlwaysPostingsFormat(new Lucene41PostingsFormat())).SetMergePolicy(NewLogMergePolicy()));
Term term = new Term("test", "a");
for (int i = 0; i < 5000; i++)
{
Document d1 = new Document();
d1.Add(NewTextField(term.Field(), term.Text(), Field.Store.NO));
writer.AddDocument(d1);
}
writer.Commit();
writer.ForceMerge(1);
writer.Dispose();
AtomicReader reader = GetOnlySegmentReader(DirectoryReader.Open(dir));
for (int i = 0; i < 2; i++)
{
Counter = 0;
DocsAndPositionsEnum tp = reader.TermPositionsEnum(term);
CheckSkipTo(tp, 14, 185); // no skips
CheckSkipTo(tp, 17, 190); // one skip on level 0
CheckSkipTo(tp, 287, 200); // one skip on level 1, two on level 0
// this test would fail if we had only one skip level,
// because than more bytes would be read from the freqStream
CheckSkipTo(tp, 4800, 250); // one skip on level 2
}
}