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

C# Search.DisjunctionMaxQuery类代码示例

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

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



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

示例1: Search

		public Result Search (string term, int count, int start) {
			try {
				term = term.ToLower ();
				Term htTerm = new Term ("hottext", term);
				Query qq1 = new FuzzyQuery (htTerm);
				Query qq2 = new TermQuery (htTerm);
				qq2.Boost = 10f;
				Query qq3 = new PrefixQuery (htTerm);
				qq3.Boost = 10f;
				DisjunctionMaxQuery q1 = new DisjunctionMaxQuery (0f);
				q1.Add (qq1);
				q1.Add (qq2);
				q1.Add (qq3);
				Query q2 = new TermQuery (new Term ("text", term));
				q2.Boost = 3f;
				Query q3 = new TermQuery (new Term ("examples", term));
				q3.Boost = 3f;
				DisjunctionMaxQuery q = new DisjunctionMaxQuery (0f);

				q.Add (q1);
				q.Add (q2);
				q.Add (q3);
			
				TopDocs top = SearchInternal (q, count, start);
				Result r = new Result (term, searcher, top.ScoreDocs);
				Results.Add (r);
				return r;
			} catch (IOException) {
				Console.WriteLine ("No index in {0}", dir);
				return null;
			}
		}
开发者ID:runefs,项目名称:Marvin_mono,代码行数:32,代码来源:SearchableIndex.cs


示例2: Test1

        public virtual void Test1()
        {
            BooleanQuery q = new BooleanQuery();

            PhraseQuery phraseQuery = new PhraseQuery();
            phraseQuery.Slop = 1;
            phraseQuery.Add(new Term(FIELD, "w1"));
            phraseQuery.Add(new Term(FIELD, "w2"));
            q.Add(phraseQuery, Occur.MUST);
            q.Add(Snear(St("w2"), Sor("w5", "zz"), 4, true), Occur.SHOULD);
            q.Add(Snear(Sf("w3", 2), St("w2"), St("w3"), 5, true), Occur.SHOULD);

            Query t = new FilteredQuery(new TermQuery(new Term(FIELD, "xx")), new ItemizedFilter(new int[] { 1, 3 }));
            t.Boost = 1000;
            q.Add(t, Occur.SHOULD);

            t = new ConstantScoreQuery(new ItemizedFilter(new int[] { 0, 2 }));
            t.Boost = 30;
            q.Add(t, Occur.SHOULD);

            DisjunctionMaxQuery dm = new DisjunctionMaxQuery(0.2f);
            dm.Add(Snear(St("w2"), Sor("w5", "zz"), 4, true));
            dm.Add(new TermQuery(new Term(FIELD, "QQ")));

            BooleanQuery xxYYZZ = new BooleanQuery();
            xxYYZZ.Add(new TermQuery(new Term(FIELD, "xx")), Occur.SHOULD);
            xxYYZZ.Add(new TermQuery(new Term(FIELD, "yy")), Occur.SHOULD);
            xxYYZZ.Add(new TermQuery(new Term(FIELD, "zz")), Occur.MUST_NOT);

            dm.Add(xxYYZZ);

            BooleanQuery xxW1 = new BooleanQuery();
            xxW1.Add(new TermQuery(new Term(FIELD, "xx")), Occur.MUST_NOT);
            xxW1.Add(new TermQuery(new Term(FIELD, "w1")), Occur.MUST_NOT);

            dm.Add(xxW1);

            DisjunctionMaxQuery dm2 = new DisjunctionMaxQuery(0.5f);
            dm2.Add(new TermQuery(new Term(FIELD, "w1")));
            dm2.Add(new TermQuery(new Term(FIELD, "w2")));
            dm2.Add(new TermQuery(new Term(FIELD, "w3")));
            dm.Add(dm2);

            q.Add(dm, Occur.SHOULD);

            BooleanQuery b = new BooleanQuery();
            b.MinimumNumberShouldMatch = 2;
            b.Add(Snear("w1", "w2", 1, true), Occur.SHOULD);
            b.Add(Snear("w2", "w3", 1, true), Occur.SHOULD);
            b.Add(Snear("w1", "w3", 3, true), Occur.SHOULD);

            q.Add(b, Occur.SHOULD);

            Qtest(q, new int[] { 0, 1, 2 });
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:55,代码来源:TestComplexExplanations.cs


示例3: TestDisjunctionSumVersusDisjunctionMax

 public virtual void TestDisjunctionSumVersusDisjunctionMax()
 {
     Term t1 = RandomTerm();
     Term t2 = RandomTerm();
     BooleanQuery q1 = new BooleanQuery();
     q1.Add(new TermQuery(t1), Occur.SHOULD);
     q1.Add(new TermQuery(t2), Occur.SHOULD);
     DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.5f);
     q2.Add(new TermQuery(t1));
     q2.Add(new TermQuery(t2));
     AssertSameSet(q1, q2);
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:12,代码来源:TestSimpleSearchEquivalence.cs


示例4: GetQuery

        /// <summary>
        /// (non-Javadoc)
        /// @see org.apache.lucene.xmlparser.QueryObjectBuilder#process(org.w3c.dom.Element)
        /// </summary>
        public virtual Query GetQuery(XmlElement e)
        {
            float tieBreaker = DOMUtils.GetAttribute(e, "tieBreaker", 0.0f);
            DisjunctionMaxQuery dq = new DisjunctionMaxQuery(tieBreaker);
            dq.Boost = DOMUtils.GetAttribute(e, "boost", 1.0f);

            XmlNodeList nl = e.ChildNodes;
            for (int i = 0; i < nl.Count; i++)
            {
                XmlNode node = nl.Item(i);
                if (node is XmlElement)
                { // all elements are disjuncts.
                    XmlElement queryElem = (XmlElement)node;
                    Query q = factory.GetQuery(queryElem);
                    dq.Add(q);
                }
            }

            return dq;
        }
开发者ID:apache,项目名称:lucenenet,代码行数:24,代码来源:DisjunctionMaxQueryBuilder.cs


示例5: Test1

		public virtual void  Test1()
		{
			
			BooleanQuery q = new BooleanQuery();
			
			q.Add(qp.Parse("\"w1 w2\"~1"), Occur.MUST);
			q.Add(Snear(St("w2"), Sor("w5", "zz"), 4, true), Occur.SHOULD);
			q.Add(Snear(Sf("w3", 2), St("w2"), St("w3"), 5, true), Occur.SHOULD);
			
			Query t = new FilteredQuery(qp.Parse("xx"), new ItemizedFilter(new int[]{1, 3}));
			t.SetBoost(1000);
			q.Add(t, Occur.SHOULD);
			
			t = new ConstantScoreQuery(new ItemizedFilter(new int[]{0, 2}));
			t.SetBoost(30);
			q.Add(t, Occur.SHOULD);
			
			DisjunctionMaxQuery dm = new DisjunctionMaxQuery(0.2f);
			dm.Add(Snear(St("w2"), Sor("w5", "zz"), 4, true));
			dm.Add(qp.Parse("QQ"));
			dm.Add(qp.Parse("xx yy -zz"));
			dm.Add(qp.Parse("-xx -w1"));
			
			DisjunctionMaxQuery dm2 = new DisjunctionMaxQuery(0.5f);
			dm2.Add(qp.Parse("w1"));
			dm2.Add(qp.Parse("w2"));
			dm2.Add(qp.Parse("w3"));
			dm.Add(dm2);
			
			q.Add(dm, Occur.SHOULD);
			
			BooleanQuery b = new BooleanQuery();
			b.SetMinimumNumberShouldMatch(2);
			b.Add(Snear("w1", "w2", 1, true), Occur.SHOULD);
			b.Add(Snear("w2", "w3", 1, true), Occur.SHOULD);
			b.Add(Snear("w1", "w3", 3, true), Occur.SHOULD);
			
			q.Add(b, Occur.SHOULD);
			
			Qtest(q, new int[]{0, 1, 2});
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:41,代码来源:TestComplexExplanations.cs


示例6: TestDMQ7

 public virtual void  TestDMQ7()
 {
     DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
     q.Add(qp.Parse("-yy w3"));
     q.Add(qp.Parse("w2"));
     Qtest(q, new int[]{0, 1, 2, 3});
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:7,代码来源:TestSimpleExplanations.cs


示例7: TestDMQ3

 public virtual void  TestDMQ3()
 {
     DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
     q.Add(qp.Parse("QQ"));
     q.Add(qp.Parse("w5"));
     Qtest(q, new int[]{0});
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:7,代码来源:TestSimpleExplanations.cs


示例8: TestNullOrSubScorer

		public virtual void  TestNullOrSubScorer()
		{
			Directory dir = new MockRAMDirectory();
			IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
			Document doc = new Document();
			doc.Add(new Field("field", "a b c d", Field.Store.NO, Field.Index.ANALYZED));
			w.AddDocument(doc);
			IndexReader r = w.GetReader();
			IndexSearcher s = new IndexSearcher(r);
			BooleanQuery q = new BooleanQuery();
			q.Add(new TermQuery(new Term("field", "a")), BooleanClause.Occur.SHOULD);
			
			// PhraseQuery w/ no terms added returns a null scorer
			PhraseQuery pq = new PhraseQuery();
			q.Add(pq, BooleanClause.Occur.SHOULD);
			Assert.AreEqual(1, s.Search(q, 10).TotalHits);
			
			// A required clause which returns null scorer should return null scorer to
			// IndexSearcher.
			q = new BooleanQuery();
			pq = new PhraseQuery();
			q.Add(new TermQuery(new Term("field", "a")), BooleanClause.Occur.SHOULD);
			q.Add(pq, BooleanClause.Occur.MUST);
			Assert.AreEqual(0, s.Search(q, 10).TotalHits);
			
			DisjunctionMaxQuery dmq = new DisjunctionMaxQuery(1.0f);
			dmq.Add(new TermQuery(new Term("field", "a")));
			dmq.Add(pq);
			Assert.AreEqual(1, s.Search(dmq, 10).TotalHits);
			
			r.Close();
			w.Close();
			dir.Close();
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:34,代码来源:TestBooleanQuery.cs


示例9: TestDMQ4

 public virtual void TestDMQ4()
 {
     DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
     q.Add(new TermQuery(new Term(FIELD, "QQ")));
     q.Add(new TermQuery(new Term(FIELD, "xx")));
     Qtest(q, new int[] { 2, 3 });
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:7,代码来源:TestSimpleExplanations.cs


示例10: TestBooleanRequiredEqualScores

		public virtual void  TestBooleanRequiredEqualScores()
		{
			
			BooleanQuery q = new BooleanQuery();
			{
				DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.0f);
				q1.Add(Tq("hed", "albino"));
				q1.Add(Tq("dek", "albino"));
				q.Add(q1, BooleanClause.Occur.MUST); //false,false);
				QueryUtils.Check(q1, s);
			}
			{
				DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.0f);
				q2.Add(Tq("hed", "elephant"));
				q2.Add(Tq("dek", "elephant"));
				q.Add(q2, BooleanClause.Occur.MUST); //false,false);
				QueryUtils.Check(q2, s);
			}
			
			QueryUtils.Check(q, s);
			
			Hits h = s.Search(q);
			
			try
			{
				Assert.AreEqual(3, h.Length(), "3 docs should match " + q.ToString());
				float score = h.Score(0);
				for (int i = 1; i < h.Length(); i++)
				{
					Assert.AreEqual(score, h.Score(i), SCORE_COMP_THRESH, "score #" + i + " is not the same");
				}
			}
			catch (System.ApplicationException e)
			{
				PrintHits("testBooleanRequiredEqualScores1", h);
				throw e;
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:38,代码来源:TestDisjunctionMaxQuery.cs


示例11: TestSimpleTiebreaker

		public virtual void  TestSimpleTiebreaker()
		{
			
			DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.01f);
			q.Add(Tq("dek", "albino"));
			q.Add(Tq("dek", "elephant"));
			QueryUtils.Check(q, s);
			
			
			Hits h = s.Search(q);
			
			try
			{
				Assert.AreEqual(3, h.Length(), "3 docs should match " + q.ToString());
				Assert.AreEqual("d2", h.Doc(0).Get("id"), "wrong first");
				float score0 = h.Score(0);
				float score1 = h.Score(1);
				float score2 = h.Score(2);
				Assert.IsTrue(score0 > score1, "d2 does not have better score then others: " + score0 + " >? " + score1);
				Assert.AreEqual(score1, score2, SCORE_COMP_THRESH, "d4 and d1 don't have equal scores");
			}
			catch (System.ApplicationException e)
			{
				PrintHits("testSimpleTiebreaker", h);
				throw e;
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:27,代码来源:TestDisjunctionMaxQuery.cs


示例12: TestSimpleEqualScores3

		public virtual void  TestSimpleEqualScores3()
		{
			
			DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f);
			q.Add(Tq("hed", "albino"));
			q.Add(Tq("hed", "elephant"));
			q.Add(Tq("dek", "albino"));
			q.Add(Tq("dek", "elephant"));
			QueryUtils.Check(q, s);

			
			Hits h = s.Search(q);
			
			try
			{
				Assert.AreEqual(4, h.Length(), "all docs should match " + q.ToString());
				float score = h.Score(0);
				for (int i = 1; i < h.Length(); i++)
				{
					Assert.AreEqual(score, h.Score(i), SCORE_COMP_THRESH, "score #" + i + " is not the same");
				}
			}
			catch (System.ApplicationException e)
			{
				PrintHits("testSimpleEqualScores3", h);
				throw e;
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:28,代码来源:TestDisjunctionMaxQuery.cs


示例13: TestSkipToFirsttimeHit

		public virtual void  TestSkipToFirsttimeHit()
		{
			DisjunctionMaxQuery dq = new DisjunctionMaxQuery(0.0f);
			dq.Add(Tq("dek", "albino"));
			dq.Add(Tq("dek", "DOES_NOT_EXIST"));
			
			QueryUtils.Check(dq, s);
			
			Weight dw = dq.Weight(s);
			Scorer ds = dw.Scorer(r);
			Assert.IsTrue(ds.SkipTo(3), "firsttime skipTo found no match");
			Assert.AreEqual("d4", r.Document(ds.Doc()).Get("id"), "found wrong docid");
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:13,代码来源:TestDisjunctionMaxQuery.cs


示例14: TestSkipToFirsttimeMiss

		public virtual void  TestSkipToFirsttimeMiss()
		{
			DisjunctionMaxQuery dq = new DisjunctionMaxQuery(0.0f);
			dq.Add(Tq("id", "d1"));
			dq.Add(Tq("dek", "DOES_NOT_EXIST"));
			
			QueryUtils.Check(dq, s);
			
			Weight dw = dq.Weight(s);
			Scorer ds = dw.Scorer(r);
			bool skipOk = ds.SkipTo(3);
			if (skipOk)
			{
				Assert.Fail("firsttime skipTo found a match? ... " + r.Document(ds.Doc()).Get("id"));
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:16,代码来源:TestDisjunctionMaxQuery.cs


示例15: TestBooleanSpanQuery

        public virtual void TestBooleanSpanQuery()
        {
            int hits = 0;
            Directory directory = NewDirectory();
            Analyzer indexerAnalyzer = new MockAnalyzer(Random());

            IndexWriterConfig config = new IndexWriterConfig(TEST_VERSION_CURRENT, indexerAnalyzer);
            IndexWriter writer = new IndexWriter(directory, config);
            string FIELD = "content";
            Document d = new Document();
            d.Add(new TextField(FIELD, "clockwork orange", Field.Store.YES));
            writer.AddDocument(d);
            writer.Dispose();

            IndexReader indexReader = DirectoryReader.Open(directory);
            IndexSearcher searcher = NewSearcher(indexReader);

            DisjunctionMaxQuery query = new DisjunctionMaxQuery(1.0f);
            SpanQuery sq1 = new SpanTermQuery(new Term(FIELD, "clockwork"));
            SpanQuery sq2 = new SpanTermQuery(new Term(FIELD, "clckwork"));
            query.Add(sq1);
            query.Add(sq2);
            TopScoreDocCollector collector = TopScoreDocCollector.Create(1000, true);
            searcher.Search(query, collector);
            hits = collector.TopDocs().ScoreDocs.Length;
            foreach (ScoreDoc scoreDoc in collector.TopDocs().ScoreDocs)
            {
                Console.WriteLine(scoreDoc.Doc);
            }
            indexReader.Dispose();
            Assert.AreEqual(hits, 1);
            directory.Dispose();
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:33,代码来源:TestDisjunctionMaxQuery.cs


示例16: TestBooleanOptionalWithTiebreakerAndBoost

        public virtual void TestBooleanOptionalWithTiebreakerAndBoost()
        {
            BooleanQuery q = new BooleanQuery();
            {
                DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.01f);
                q1.Add(Tq("hed", "albino", 1.5f));
                q1.Add(Tq("dek", "albino"));
                q.Add(q1, BooleanClause.Occur.SHOULD); // false,false);
            }
            {
                DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.01f);
                q2.Add(Tq("hed", "elephant", 1.5f));
                q2.Add(Tq("dek", "elephant"));
                q.Add(q2, BooleanClause.Occur.SHOULD); // false,false);
            }
            QueryUtils.Check(Random(), q, s, Similarity);

            ScoreDoc[] h = s.Search(q, null, 1000).ScoreDocs;

            try
            {
                Assert.AreEqual(4, h.Length, "4 docs should match " + q.ToString());

                float score0 = h[0].Score;
                float score1 = h[1].Score;
                float score2 = h[2].Score;
                float score3 = h[3].Score;

                string doc0 = s.Doc(h[0].Doc).Get("id");
                string doc1 = s.Doc(h[1].Doc).Get("id");
                string doc2 = s.Doc(h[2].Doc).Get("id");
                string doc3 = s.Doc(h[3].Doc).Get("id");

                Assert.AreEqual("d4", doc0, "doc0 should be d4: ");
                Assert.AreEqual("d3", doc1, "doc1 should be d3: ");
                Assert.AreEqual("d2", doc2, "doc2 should be d2: ");
                Assert.AreEqual("d1", doc3, "doc3 should be d1: ");

                Assert.IsTrue(score0 > score1, "d4 does not have a better score then d3: " + score0 + " >? " + score1);
                Assert.IsTrue(score1 > score2, "d3 does not have a better score then d2: " + score1 + " >? " + score2);
                Assert.IsTrue(score2 > score3, "d3 does not have a better score then d1: " + score2 + " >? " + score3);
            }
            catch (Exception e)
            {
                PrintHits("TestBooleanOptionalWithTiebreakerAndBoost", h, s);
                throw e;
            }
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:48,代码来源:TestDisjunctionMaxQuery.cs


示例17: FastSearch

		public Result FastSearch (string term, int number)
		{
			try {
				term = term.ToLower ();
				Query q1 = new TermQuery (new Term ("hottext", term));
				Query q2 = new PrefixQuery (new Term ("hottext", term));
				q2.Boost = 0.5f;
				DisjunctionMaxQuery q = new DisjunctionMaxQuery (0f);
				q.Add (q1);
				q.Add (q2);
				TopDocs top = searcher.Search (q, number);
				return new Result (term, searcher, top.ScoreDocs);
			} catch (IOException) {
				Console.WriteLine ("No index in {0}", dir);
				return null;
			}
		}
开发者ID:runefs,项目名称:Marvin_mono,代码行数:17,代码来源:SearchableIndex.cs


示例18: TestBooleanOptionalNoTiebreaker

		public virtual void  TestBooleanOptionalNoTiebreaker()
		{
			
			BooleanQuery q = new BooleanQuery();
			{
				DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.0f);
				q1.Add(Tq("hed", "albino"));
				q1.Add(Tq("dek", "albino"));
				q.Add(q1, BooleanClause.Occur.SHOULD); //false,false);
			}
			{
				DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.0f);
				q2.Add(Tq("hed", "elephant"));
				q2.Add(Tq("dek", "elephant"));
				q.Add(q2, BooleanClause.Occur.SHOULD); //false,false);
			}
			QueryUtils.Check(q, s);
			
			
			Hits h = s.Search(q);
			
			try
			{
				Assert.AreEqual(4, h.Length(), "4 docs should match " + q.ToString());
				float score = h.Score(0);
				for (int i = 1; i < h.Length() - 1; i++)
				{
					/* note: -1 */
					Assert.AreEqual(score, h.Score(i), SCORE_COMP_THRESH, "score #" + i + " is not the same");
				}
				Assert.AreEqual("d1", h.Doc(h.Length() - 1).Get("id"), "wrong last");
				float score1 = h.Score(h.Length() - 1);
				Assert.IsTrue(score > score1, "d1 does not have worse score then others: " + score + " >? " + score1);
			}
			catch (System.ApplicationException e)
			{
				PrintHits("testBooleanOptionalNoTiebreaker", h);
				throw e;
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:40,代码来源:TestDisjunctionMaxQuery.cs


示例19: TestDMQ2

 public virtual void TestDMQ2()
 {
     DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
     q.Add(new TermQuery(new Term(FIELD, "w1")));
     q.Add(new TermQuery(new Term(FIELD, "w5")));
     Qtest(q, new int[] { 0, 1, 2, 3 });
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:7,代码来源:TestSimpleExplanations.cs


示例20: TestBooleanOptionalWithTiebreaker

		public virtual void  TestBooleanOptionalWithTiebreaker()
		{
			
			BooleanQuery q = new BooleanQuery();
			{
				DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.01f);
				q1.Add(Tq("hed", "albino"));
				q1.Add(Tq("dek", "albino"));
				q.Add(q1, BooleanClause.Occur.SHOULD); //false,false);
			}
			{
				DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.01f);
				q2.Add(Tq("hed", "elephant"));
				q2.Add(Tq("dek", "elephant"));
				q.Add(q2, BooleanClause.Occur.SHOULD); //false,false);
			}
			QueryUtils.Check(q, s);
			
			
			Hits h = s.Search(q);
			
			try
			{
				
				Assert.AreEqual(4, h.Length(), "4 docs should match " + q.ToString());
				
				float score0 = h.Score(0);
				float score1 = h.Score(1);
				float score2 = h.Score(2);
				float score3 = h.Score(3);
				
				System.String doc0 = h.Doc(0).Get("id");
				System.String doc1 = h.Doc(1).Get("id");
				System.String doc2 = h.Doc(2).Get("id");
				System.String doc3 = h.Doc(3).Get("id");
				
				Assert.IsTrue(doc0.Equals("d2") || doc0.Equals("d4"), "doc0 should be d2 or d4: " + doc0);
				Assert.IsTrue(doc1.Equals("d2") || doc1.Equals("d4"), "doc1 should be d2 or d4: " + doc0);
				Assert.AreEqual(score0, score1, SCORE_COMP_THRESH, "score0 and score1 should match");
				Assert.AreEqual("d3", doc2, "wrong third");
				Assert.IsTrue(score1 > score2, "d3 does not have worse score then d2 and d4: " + score1 + " >? " + score2);
				
				Assert.AreEqual("d1", doc3, "wrong fourth");
				Assert.IsTrue(score2 > score3, "d1 does not have worse score then d3: " + score2 + " >? " + score3);
			}
			catch (System.ApplicationException e)
			{
				PrintHits("testBooleanOptionalWithTiebreaker", h);
				throw e;
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:51,代码来源:TestDisjunctionMaxQuery.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Search.Explanation类代码示例发布时间:2022-05-26
下一篇:
C# Search.ConstantScoreQuery类代码示例发布时间: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