• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Spans.SpanOrQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: InitBlock

			private void  InitBlock(Lucene.Net.Index.IndexReader reader, SpanOrQuery enclosingInstance)
			{
				this.reader = reader;
				this.enclosingInstance = enclosingInstance;
				all = new System.Collections.ArrayList(Enclosing_Instance.clauses.Count);
				queue = new SpanQueue(enclosingInstance, Enclosing_Instance.clauses.Count);
				System.Collections.IEnumerator i = Enclosing_Instance.clauses.GetEnumerator();
				while (i.MoveNext())
				{
					// initialize all
					all.Add(((SpanQuery) i.Current).GetSpans(reader));
				}
			}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:13,代码来源:SpanOrQuery.cs


示例2: Clone

        public override System.Object Clone()
        {
            int sz = clauses.Count;
            SpanQuery[] newClauses = new SpanQuery[sz];

            for (int i = 0; i < sz; i++)
            {
                SpanQuery clause = (SpanQuery) clauses[i];
                newClauses[i] = (SpanQuery) clause.Clone();
            }
            SpanOrQuery soq = new SpanOrQuery(newClauses);
            soq.SetBoost(GetBoost());
            return soq;
        }
开发者ID:sinsay,项目名称:SSE,代码行数:14,代码来源:SpanOrQuery.cs


示例3: 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


示例4: VisitQuery

 private static void VisitQuery(SpanOrQuery query, AzureQueryLogger.IndentedTextWriter writer)
 {
     SpanQuery[] clauses = query.GetClauses();
     AzureQueryLogger.VisitClauses(writer, clauses);
 }
开发者ID:jscott1277,项目名称:SitecoreAzureSearchProvider,代码行数:5,代码来源:AzureQueryLogger.cs


示例5: TestSpanComplex1

		public virtual void  TestSpanComplex1()
		{
			
			SpanTermQuery t1 = new SpanTermQuery(new Term("Field", "six"));
			SpanTermQuery t2 = new SpanTermQuery(new Term("Field", "hundred"));
			SpanNearQuery tt1 = new SpanNearQuery(new SpanQuery[]{t1, t2}, 0, true);
			
			SpanTermQuery t3 = new SpanTermQuery(new Term("Field", "seven"));
			SpanTermQuery t4 = new SpanTermQuery(new Term("Field", "hundred"));
			SpanNearQuery tt2 = new SpanNearQuery(new SpanQuery[]{t3, t4}, 0, true);
			
			SpanTermQuery t5 = new SpanTermQuery(new Term("Field", "seven"));
			SpanTermQuery t6 = new SpanTermQuery(new Term("Field", "six"));
			
			SpanOrQuery to1 = new SpanOrQuery(new SpanQuery[]{tt1, tt2});
			SpanOrQuery to2 = new SpanOrQuery(new SpanQuery[]{t5, t6});
			
			SpanNearQuery query = new SpanNearQuery(new SpanQuery[]{to1, to2}, 100, true);
			
			CheckHits(query, new int[]{606, 607, 626, 627, 636, 637, 646, 647, 656, 657, 666, 667, 676, 677, 686, 687, 696, 697, 706, 707, 726, 727, 736, 737, 746, 747, 756, 757, 766, 767, 776, 777, 786, 787, 796, 797});
		}
开发者ID:emtees,项目名称:old-code,代码行数:21,代码来源:TestBasics.cs


示例6: TestSpanOr

		public virtual void  TestSpanOr()
		{
			SpanTermQuery term1 = new SpanTermQuery(new Term("Field", "thirty"));
			SpanTermQuery term2 = new SpanTermQuery(new Term("Field", "three"));
			SpanNearQuery near1 = new SpanNearQuery(new SpanQuery[]{term1, term2}, 0, true);
			SpanTermQuery term3 = new SpanTermQuery(new Term("Field", "forty"));
			SpanTermQuery term4 = new SpanTermQuery(new Term("Field", "seven"));
			SpanNearQuery near2 = new SpanNearQuery(new SpanQuery[]{term3, term4}, 0, true);
			
			SpanOrQuery query = new SpanOrQuery(new SpanQuery[]{near1, near2});
			
			CheckHits(query, new int[]{33, 47, 133, 147, 233, 247, 333, 347, 433, 447, 533, 547, 633, 647, 733, 747, 833, 847, 933, 947});
			
			Assert.IsTrue(searcher.Explain(query, 33).GetValue() > 0.0f);
			Assert.IsTrue(searcher.Explain(query, 947).GetValue() > 0.0f);
		}
开发者ID:emtees,项目名称:old-code,代码行数:16,代码来源:TestBasics.cs


示例7: TestSpanOrVersusBoolean

 public virtual void TestSpanOrVersusBoolean()
 {
     Term t1 = RandomTerm();
     Term t2 = RandomTerm();
     BooleanQuery q1 = new BooleanQuery();
     q1.Add(new TermQuery(t1), Occur.SHOULD);
     q1.Add(new TermQuery(t2), Occur.SHOULD);
     SpanOrQuery q2 = new SpanOrQuery(new SpanTermQuery(t1), new SpanTermQuery(t2));
     AssertSameSet(q1, q2);
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:10,代码来源:TestSpanSearchEquivalence.cs


示例8: SpanQueue

 public SpanQueue(SpanOrQuery enclosingInstance, int size)
 {
     InitBlock(enclosingInstance);
     Initialize(size);
 }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:5,代码来源:SpanOrQuery.cs


示例9: TestSpanOrEmpty

        public virtual void TestSpanOrEmpty()
        {
            Spans spans = OrSpans(new string[0]);
            Assert.IsFalse(spans.Next(), "empty next");

            SpanOrQuery a = new SpanOrQuery();
            SpanOrQuery b = new SpanOrQuery();
            Assert.IsTrue(a.Equals(b), "empty should equal");
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:9,代码来源:TestSpans.cs


示例10: TestSpans2

        public virtual void TestSpans2()
        {
            AssumeTrue("Broken scoring: LUCENE-3723", Searcher.Similarity is TFIDFSimilarity);
            SpanQuery qA1 = new SpanTermQuery(new Term("gender", "female"));
            SpanQuery qA2 = new SpanTermQuery(new Term("first", "james"));
            SpanQuery qA = new SpanOrQuery(qA1, new FieldMaskingSpanQuery(qA2, "gender"));
            SpanQuery qB = new SpanTermQuery(new Term("last", "jones"));
            SpanQuery q = new SpanNearQuery(new SpanQuery[] { new FieldMaskingSpanQuery(qA, "id"), new FieldMaskingSpanQuery(qB, "id") }, -1, false);
            Check(q, new int[] { 0, 1, 2, 3 });

            Spans span = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, q);

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(0, 0, 1), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(1, 1, 2), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(2, 0, 1), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(2, 2, 3), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(3, 0, 1), s(span));

            Assert.AreEqual(false, span.Next());
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:29,代码来源:TestFieldMaskingSpanQuery.cs


示例11: TestSpans2

		public virtual void  TestSpans2()
		{
			SpanQuery qA1 = new SpanTermQuery(new Term("gender", "female"));
			SpanQuery qA2 = new SpanTermQuery(new Term("first", "james"));
			SpanQuery qA = new SpanOrQuery(new SpanQuery[]{qA1, new FieldMaskingSpanQuery(qA2, "gender")});
			SpanQuery qB = new SpanTermQuery(new Term("last", "jones"));
			SpanQuery q = new SpanNearQuery(new SpanQuery[]{new FieldMaskingSpanQuery(qA, "id"), new FieldMaskingSpanQuery(qB, "id")}, - 1, false);
			Check(q, new int[]{0, 1, 2, 3});
			
			Spans span = q.GetSpans(searcher.GetIndexReader());
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(0, 0, 1), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(1, 1, 2), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(2, 0, 1), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(2, 2, 3), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(3, 0, 1), S(span));
			
			Assert.AreEqual(false, span.Next());
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:28,代码来源:TestFieldMaskingSpanQuery.cs


示例12: 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(new SpanQuery[]{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 = qA.GetSpans(searcher.GetIndexReader());
			Spans spanB = qB.GetSpans(searcher.GetIndexReader());
			
			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:VirtueMe,项目名称:ravendb,代码行数:20,代码来源:TestFieldMaskingSpanQuery.cs


示例13: TestSpans0

		public virtual void  TestSpans0()
		{
			SpanQuery q1 = new SpanTermQuery(new Term("gender", "female"));
			SpanQuery q2 = new SpanTermQuery(new Term("first", "james"));
			SpanQuery q = new SpanOrQuery(new SpanQuery[]{q1, new FieldMaskingSpanQuery(q2, "gender")});
			Check(q, new int[]{0, 1, 2, 3, 4});
			
			Spans span = q.GetSpans(searcher.GetIndexReader());
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(0, 0, 1), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(1, 0, 1), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(1, 1, 2), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(2, 0, 1), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(2, 1, 2), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(2, 2, 3), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(3, 0, 1), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(4, 0, 1), S(span));
			
			Assert.AreEqual(true, span.Next());
			Assert.AreEqual(S(4, 1, 2), S(span));
			
			Assert.AreEqual(false, span.Next());
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:38,代码来源:TestFieldMaskingSpanQuery.cs


示例14: VisitSpanOrQuery

 public virtual Query VisitSpanOrQuery(SpanOrQuery spanOrq) { throw new NotImplementedException(); }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:1,代码来源:LucQueryVisitor.cs


示例15: TestNoSuchMultiTermsInOr

        public virtual void TestNoSuchMultiTermsInOr()
        {
            //test to make sure non existent multiterms aren't throwing null pointer exceptions
            FuzzyQuery fuzzyNoSuch = new FuzzyQuery(new Term("field", "noSuch"), 1, 0, 1, false);
            SpanQuery spanNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(fuzzyNoSuch);
            SpanQuery term = new SpanTermQuery(new Term("field", "brown"));
            SpanOrQuery near = new SpanOrQuery(new SpanQuery[] { term, spanNoSuch });
            Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);

            //flip
            near = new SpanOrQuery(new SpanQuery[] { spanNoSuch, term });
            Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);

            WildcardQuery wcNoSuch = new WildcardQuery(new Term("field", "noSuch*"));
            SpanQuery spanWCNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(wcNoSuch);
            near = new SpanOrQuery(new SpanQuery[] { term, spanWCNoSuch });
            Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);

            RegexpQuery rgxNoSuch = new RegexpQuery(new Term("field", "noSuch"));
            SpanQuery spanRgxNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(rgxNoSuch);
            near = new SpanOrQuery(new SpanQuery[] { term, spanRgxNoSuch });
            Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);

            PrefixQuery prfxNoSuch = new PrefixQuery(new Term("field", "noSuch"));
            SpanQuery spanPrfxNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(prfxNoSuch);
            near = new SpanOrQuery(new SpanQuery[] { term, spanPrfxNoSuch });
            Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);

            near = new SpanOrQuery(new SpanQuery[] { spanPrfxNoSuch });
            Assert.AreEqual(0, Searcher.Search(near, 10).TotalHits);

            near = new SpanOrQuery(new SpanQuery[] { spanPrfxNoSuch, spanPrfxNoSuch });
            Assert.AreEqual(0, Searcher.Search(near, 10).TotalHits);
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:34,代码来源:TestSpanMultiTermQueryWrapper.cs


示例16: TestSpans0

        public virtual void TestSpans0()
        {
            SpanQuery q1 = new SpanTermQuery(new Term("gender", "female"));
            SpanQuery q2 = new SpanTermQuery(new Term("first", "james"));
            SpanQuery q = new SpanOrQuery(q1, new FieldMaskingSpanQuery(q2, "gender"));
            Check(q, new int[] { 0, 1, 2, 3, 4 });

            Spans span = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, q);

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(0, 0, 1), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(1, 0, 1), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(1, 1, 2), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(2, 0, 1), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(2, 1, 2), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(2, 2, 3), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(3, 0, 1), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(4, 0, 1), s(span));

            Assert.AreEqual(true, span.Next());
            Assert.AreEqual(s(4, 1, 2), s(span));

            Assert.AreEqual(false, span.Next());
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:38,代码来源:TestFieldMaskingSpanQuery.cs


示例17: 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


示例18: TestSpanWithMultipleNotMany

		public virtual void  TestSpanWithMultipleNotMany()
		{
			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"));
			SpanTermQuery term4 = new SpanTermQuery(new Term("field", "sixty"));
			SpanTermQuery term5 = new SpanTermQuery(new Term("field", "eighty"));
			
			SpanOrQuery or = new SpanOrQuery(new SpanQuery[]{term3, term4, term5});
			
			SpanNotQuery query = new SpanNotQuery(near, or);
			
			CheckHits(query, new int[]{801, 821, 831, 851, 871, 891});
			
			Assert.IsTrue(searcher.Explain(query, 801).GetValue() > 0.0f);
			Assert.IsTrue(searcher.Explain(query, 891).GetValue() > 0.0f);
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:18,代码来源:TestBasics.cs


示例19: InitBlock

			private void  InitBlock(Lucene.Net.Index.IndexReader reader, SpanOrQuery enclosingInstance)
			{
				this.reader = reader;
				this.enclosingInstance = enclosingInstance;
			}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:5,代码来源:SpanOrQuery.cs


示例20: AddComplexPhraseClause

            private void AddComplexPhraseClause(List<SpanQuery> spanClauses, BooleanQuery qc)
            {
                List<SpanQuery> ors = new List<SpanQuery>();
                List<SpanQuery> nots = new List<SpanQuery>();
                BooleanClause[] bclauses = qc.Clauses;

                // For all clauses e.g. one* two~
                for (int i = 0; i < bclauses.Length; i++)
                {
                    Query childQuery = bclauses[i].Query;

                    // select the list to which we will add these options
                    List<SpanQuery> chosenList = ors;
                    if (bclauses[i].Occur_ == BooleanClause.Occur.MUST_NOT)
                    {
                        chosenList = nots;
                    }

                    if (childQuery is TermQuery)
                    {
                        TermQuery tq = (TermQuery)childQuery;
                        SpanTermQuery stq = new SpanTermQuery(tq.Term);
                        stq.Boost = tq.Boost;
                        chosenList.Add(stq);
                    }
                    else if (childQuery is BooleanQuery)
                    {
                        BooleanQuery cbq = (BooleanQuery)childQuery;
                        AddComplexPhraseClause(chosenList, cbq);
                    }
                    else
                    {
                        // LUCENETODO alternatively could call extract terms here?
                        throw new ArgumentException("Unknown query type:"
                            + childQuery.GetType().Name);
                    }
                }
                if (ors.Count == 0)
                {
                    return;
                }
                SpanOrQuery soq = new SpanOrQuery(ors
                    .ToArray());
                if (nots.Count == 0)
                {
                    spanClauses.Add(soq);
                }
                else
                {
                    SpanOrQuery snqs = new SpanOrQuery(nots
                        .ToArray());
                    SpanNotQuery snq = new SpanNotQuery(soq, snqs);
                    spanClauses.Add(snq);
                }
            }
开发者ID:apache,项目名称:lucenenet,代码行数:55,代码来源:ComplexPhraseQueryParser.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Spans.SpanQuery类代码示例发布时间:2022-05-26
下一篇:
C# Spans.SpanNearQuery类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap