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


C# Spans.SpanTermQuery类代码示例

本文整理汇总了C#中Lucene.Net.Search.Spans.SpanTermQuery的典型用法代码示例。如果您正苦于以下问题:C# SpanTermQuery类的具体用法?C# SpanTermQuery怎么用?C# SpanTermQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SpanTermQuery类属于Lucene.Net.Search.Spans命名空间,在下文中一共展示了SpanTermQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSingleSpanQuery

		public virtual void  TestSingleSpanQuery()
		{
			
			Query spanQuery = new SpanTermQuery(new Term(FIELD_TEXT, "should"));
			System.String[] expectedIds = new System.String[]{"B", "D", "1", "2", "3", "4", "A"};
			float[] expectedScores = new float[]{0.625f, 0.45927936f, 0.35355338f, 0.35355338f, 0.35355338f, 0.35355338f, 0.26516503f};
			assertHits(searcher2, spanQuery, "single span query", expectedIds, expectedScores);
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:8,代码来源:TestSpansAdvanced2.cs

示例2: GetSpanQuery

        public override SpanQuery GetSpanQuery(XmlElement e)
        {
            string fieldName = DOMUtils.GetAttributeWithInheritanceOrFail(e, "fieldName");
            string value = DOMUtils.GetNonBlankTextOrFail(e);
            SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, value));

            stq.Boost = DOMUtils.GetAttribute(e, "boost", 1.0f);
            return stq;
        }
开发者ID:apache,项目名称:lucenenet,代码行数:9,代码来源:SpanTermBuilder.cs

示例3: TestSpanTermQuery

		public virtual void  TestSpanTermQuery()
		{
			SpanTermQuery stq;
			Spans spans;
			stq = new SpanTermQuery(new Term(PayloadHelper.FIELD, "seventy"));
			spans = stq.GetSpans(indexReader);
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 100, 1, 1, 1);
			
			stq = new SpanTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "seventy"));
			spans = stq.GetSpans(indexReader);
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 100, 0, 0, 0);
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:14,代码来源:TestPayloadSpans.cs

示例4: TestSpanFirst

        public virtual void TestSpanFirst()
        {
            SpanQuery match;
            SpanFirstQuery sfq;
            match = new SpanTermQuery(new Term(PayloadHelper.FIELD, "one"));
            sfq = new SpanFirstQuery(match, 2);
            Spans spans = MultiSpansWrapper.Wrap(IndexReader.Context, sfq);
            CheckSpans(spans, 109, 1, 1, 1);
            //Test more complicated subclause
            SpanQuery[] clauses = new SpanQuery[2];
            clauses[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "one"));
            clauses[1] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "hundred"));
            match = new SpanNearQuery(clauses, 0, true);
            sfq = new SpanFirstQuery(match, 2);
            CheckSpans(MultiSpansWrapper.Wrap(IndexReader.Context, sfq), 100, 2, 1, 1);

            match = new SpanNearQuery(clauses, 0, false);
            sfq = new SpanFirstQuery(match, 2);
            CheckSpans(MultiSpansWrapper.Wrap(IndexReader.Context, sfq), 100, 2, 1, 1);
        }
开发者ID:joyanta,项目名称:lucene.net,代码行数:20,代码来源:TestPayloadSpans.cs

示例5: GetSpanQuery

        public override SpanQuery GetSpanQuery(XmlElement e)
        {
            string fieldName = DOMUtils.GetAttributeWithInheritanceOrFail(e, "fieldName");
            string value = DOMUtils.GetNonBlankTextOrFail(e);

            List<SpanQuery> clausesList = new List<SpanQuery>();

            TokenStream ts = null;
            try
            {
                ts = analyzer.TokenStream(fieldName, value);
                ITermToBytesRefAttribute termAtt = ts.AddAttribute<ITermToBytesRefAttribute>();
                BytesRef bytes = termAtt.BytesRef;
                ts.Reset();
                while (ts.IncrementToken())
                {
                    termAtt.FillBytesRef();
                    SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, BytesRef.DeepCopyOf(bytes)));
                    clausesList.Add(stq);
                }
                ts.End();
                SpanOrQuery soq = new SpanOrQuery(clausesList.ToArray(/*new SpanQuery[clausesList.size()]*/));
                soq.Boost = DOMUtils.GetAttribute(e, "boost", 1.0f);
                return soq;
            }
#pragma warning disable 168
            catch (IOException ioe)
#pragma warning restore 168
            {
                throw new ParserException("IOException parsing value:" + value);
            }
            finally
            {
                IOUtils.CloseWhileHandlingException(ts);
            }
        }
开发者ID:apache,项目名称:lucenenet,代码行数:36,代码来源:SpanOrTermsBuilder.cs

示例6: doTestBooleanQueryWithSpanQueries

 /// <summary> Tests two span queries.
 /// 
 /// </summary>
 /// <throws>  IOException </throws>
 protected internal virtual void  doTestBooleanQueryWithSpanQueries(IndexSearcher s, float expectedScore)
 {
     
     Query spanQuery = new SpanTermQuery(new Term(FIELD_TEXT, "work"));
     BooleanQuery query = new BooleanQuery();
     query.Add(spanQuery, Occur.MUST);
     query.Add(spanQuery, Occur.MUST);
     System.String[] expectedIds = new System.String[]{"1", "2", "3", "4"};
     float[] expectedScores = new float[]{expectedScore, expectedScore, expectedScore, expectedScore};
     assertHits(s, query, "two span queries", expectedIds, expectedScores);
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:15,代码来源:TestSpansAdvanced.cs

示例7: InitBlock

 private void InitBlock(Lucene.Net.Index.IndexReader reader, SpanTermQuery enclosingInstance)
 {
     this.reader = reader;
     this.enclosingInstance = enclosingInstance;
     positions = reader.TermPositions(Enclosing_Instance.term);
 }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:6,代码来源:SpanTermQuery.cs

示例8: TestSpans1

        public virtual void TestSpans1()
        {
            SpanQuery q1 = new SpanTermQuery(new Term("first", "sally"));
            SpanQuery q2 = new SpanTermQuery(new Term("first", "james"));
            SpanQuery qA = new SpanOrQuery(q1, q2);
            SpanQuery qB = new FieldMaskingSpanQuery(qA, "id");

            Check(qA, new int[] { 0, 1, 2, 4 });
            Check(qB, new int[] { 0, 1, 2, 4 });

            Spans spanA = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, qA);
            Spans spanB = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, qB);

            while (spanA.Next())
            {
                Assert.IsTrue(spanB.Next(), "spanB not still going");
                Assert.AreEqual(s(spanA), s(spanB), "spanA not equal spanB");
            }
            Assert.IsTrue(!(spanB.Next()), "spanB still going even tough spanA is done");
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:20,代码来源:TestFieldMaskingSpanQuery.cs

示例9: TestSimple2

 public virtual void TestSimple2()
 {
     AssumeTrue("Broken scoring: LUCENE-3723", Searcher.Similarity is TFIDFSimilarity);
     SpanQuery q1 = new SpanTermQuery(new Term("gender", "female"));
     SpanQuery q2 = new SpanTermQuery(new Term("last", "smith"));
     SpanQuery q = new SpanNearQuery(new SpanQuery[] { q1, new FieldMaskingSpanQuery(q2, "gender") }, -1, false);
     Check(q, new int[] { 2, 4 });
     q = new SpanNearQuery(new SpanQuery[] { new FieldMaskingSpanQuery(q1, "id"), new FieldMaskingSpanQuery(q2, "id") }, -1, false);
     Check(q, new int[] { 2, 4 });
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:10,代码来源:TestFieldMaskingSpanQuery.cs

示例10: TestRewrite2

        public virtual void TestRewrite2()
        {
            SpanQuery q1 = new SpanTermQuery(new Term("last", "smith"));
            SpanQuery q2 = new SpanTermQuery(new Term("last", "jones"));
            SpanQuery q = new SpanNearQuery(new SpanQuery[] { q1, new FieldMaskingSpanQuery(q2, "last") }, 1, true);
            Query qr = Searcher.Rewrite(q);

            QueryUtils.CheckEqual(q, qr);

            HashSet<Term> set = new HashSet<Term>();
            qr.ExtractTerms(set);
            Assert.AreEqual(2, set.Count);
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:13,代码来源:TestFieldMaskingSpanQuery.cs

示例11: TestSpanNearUnordered

		public virtual void  TestSpanNearUnordered()
		{
			SpanTermQuery term1 = new SpanTermQuery(new Term("Field", "nine"));
			SpanTermQuery term2 = new SpanTermQuery(new Term("Field", "six"));
			SpanNearQuery query = new SpanNearQuery(new SpanQuery[]{term1, term2}, 4, false);
			
			CheckHits(query, new int[]{609, 629, 639, 649, 659, 669, 679, 689, 699, 906, 926, 936, 946, 956, 966, 976, 986, 996});
		}
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:TestBasics.cs

示例12: TestSpanNearExact

		public virtual void  TestSpanNearExact()
		{
			SpanTermQuery term1 = new SpanTermQuery(new Term("Field", "seventy"));
			SpanTermQuery term2 = new SpanTermQuery(new Term("Field", "seven"));
			SpanNearQuery query = new SpanNearQuery(new SpanQuery[]{term1, term2}, 0, true);
			CheckHits(query, new int[]{77, 177, 277, 377, 477, 577, 677, 777, 877, 977});
			
			Assert.IsTrue(searcher.Explain(query, 77).GetValue() > 0.0f);
			Assert.IsTrue(searcher.Explain(query, 977).GetValue() > 0.0f);
		}
开发者ID:emtees,项目名称:old-code,代码行数:10,代码来源:TestBasics.cs

示例13: TestSpanWithMultipleNotSingle

        public virtual void TestSpanWithMultipleNotSingle()
        {
            SpanTermQuery term1 = new SpanTermQuery(new Term("field", "eight"));
            SpanTermQuery term2 = new SpanTermQuery(new Term("field", "one"));
            SpanNearQuery near = new SpanNearQuery(new SpanQuery[] { term1, term2 }, 4, true);
            SpanTermQuery term3 = new SpanTermQuery(new Term("field", "forty"));

            SpanOrQuery or = new SpanOrQuery(term3);

            SpanNotQuery query = new SpanNotQuery(near, or);

            CheckHits(query, new int[] { 801, 821, 831, 851, 861, 871, 881, 891, 1801, 1821, 1831, 1851, 1861, 1871, 1881, 1891 });

            Assert.IsTrue(Searcher.Explain(query, 801).Value > 0.0f);
            Assert.IsTrue(Searcher.Explain(query, 891).Value > 0.0f);
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:16,代码来源:TestBasics.cs

示例14: TestSpanTermQuery

 public virtual void TestSpanTermQuery()
 {
     SpanTermQuery term1 = new SpanTermQuery(new Term("field", "seventy"));
     CheckHits(term1, new int[] { 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1170, 1270, 1370, 1470, 1570, 1670, 1770, 1870, 1970, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979 });
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:5,代码来源:TestBasics.cs

示例15: TestSpansSkipTo

        public virtual void TestSpansSkipTo()
        {
            SpanTermQuery t1 = new SpanTermQuery(new Term("field", "seventy"));
            SpanTermQuery t2 = new SpanTermQuery(new Term("field", "seventy"));
            Spans s1 = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, t1);
            Spans s2 = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, t2);

            Assert.IsTrue(s1.Next());
            Assert.IsTrue(s2.Next());

            bool hasMore = true;

            do
            {
                hasMore = SkipToAccoringToJavaDocs(s1, s1.Doc() + 1);
                Assert.AreEqual(hasMore, s2.SkipTo(s2.Doc() + 1));
                Assert.AreEqual(s1.Doc(), s2.Doc());
            } while (hasMore);
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:19,代码来源:TestBasics.cs


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