当前位置: 首页>>代码示例>>C#>>正文


C# Term.Field方法代码示例

本文整理汇总了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)));
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:13,代码来源:RegexTermEnum.cs

示例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
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:33,代码来源:TestMultiLevelSkipList.cs

示例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;
 }
开发者ID:uvbs,项目名称:MyProjects,代码行数:10,代码来源:ContainTermEnum.cs

示例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;
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:12,代码来源:RegexTermEnum.cs

示例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;
 }
开发者ID:paulirwin,项目名称:lucene.net,代码行数:13,代码来源:TermFilter.cs

示例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;
        }
开发者ID:joyanta,项目名称:lucene.net,代码行数:15,代码来源:TestIndexWriterReader.cs

示例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;
 }
开发者ID:suifengshiqu,项目名称:nluke,代码行数:21,代码来源:TermDocumentsRelation.cs

示例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;
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:43,代码来源:DuplicateFilter.cs

示例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;
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:38,代码来源:DuplicateFilter.cs

示例10: Seek

			public override void  Seek(Term term)
			{
				IndexReader reader = ((IndexReader) Enclosing_Instance.fieldToReader[term.Field()]);
				termDocs = reader != null?reader.TermPositions(term):null;
			}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:5,代码来源:ParallelReader.cs

示例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);
            }
        }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:40,代码来源:LucQueryVisitor.cs

示例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;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:21,代码来源:TermBuffer.cs

示例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);
			}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:8,代码来源:ParallelReader.cs

示例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();
 }
开发者ID:joyanta,项目名称:lucene.net,代码行数:12,代码来源:TestAddIndexes.cs

示例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
            }
        }
开发者ID:paulirwin,项目名称:lucene.net,代码行数:30,代码来源:TestMultiLevelSkipList.cs


注:本文中的Lucene.Net.Index.Term.Field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。