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


C# FilteredQuery.GetBoost方法代码示例

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


在下文中一共展示了FilteredQuery.GetBoost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestFilteredQuery_Renamed

		public virtual void  TestFilteredQuery_Renamed()
		{
			Query filteredquery = new FilteredQuery(query, filter);
			ScoreDoc[] hits = searcher.Search(filteredquery, null, 1000).scoreDocs;
			Assert.AreEqual(1, hits.Length);
			Assert.AreEqual(1, hits[0].doc);
			QueryUtils.Check(filteredquery, searcher);
			
			hits = searcher.Search(filteredquery, null, 1000, new Sort("sorter")).scoreDocs;
			Assert.AreEqual(1, hits.Length);
			Assert.AreEqual(1, hits[0].doc);
			
			filteredquery = new FilteredQuery(new TermQuery(new Term("field", "one")), filter);
			hits = searcher.Search(filteredquery, null, 1000).scoreDocs;
			Assert.AreEqual(2, hits.Length);
			QueryUtils.Check(filteredquery, searcher);
			
			filteredquery = new FilteredQuery(new TermQuery(new Term("field", "x")), filter);
			hits = searcher.Search(filteredquery, null, 1000).scoreDocs;
			Assert.AreEqual(1, hits.Length);
			Assert.AreEqual(3, hits[0].doc);
			QueryUtils.Check(filteredquery, searcher);
			
			filteredquery = new FilteredQuery(new TermQuery(new Term("field", "y")), filter);
			hits = searcher.Search(filteredquery, null, 1000).scoreDocs;
			Assert.AreEqual(0, hits.Length);
			QueryUtils.Check(filteredquery, searcher);
			
			// test boost
			Filter f = NewStaticFilterA();
			
			float boost = 2.5f;
			BooleanQuery bq1 = new BooleanQuery();
			TermQuery tq = new TermQuery(new Term("field", "one"));
			tq.SetBoost(boost);
			bq1.Add(tq, Occur.MUST);
			bq1.Add(new TermQuery(new Term("field", "five")), Occur.MUST);
			
			BooleanQuery bq2 = new BooleanQuery();
			tq = new TermQuery(new Term("field", "one"));
			filteredquery = new FilteredQuery(tq, f);
			filteredquery.SetBoost(boost);
			bq2.Add(filteredquery, Occur.MUST);
			bq2.Add(new TermQuery(new Term("field", "five")), Occur.MUST);
			AssertScoreEquals(bq1, bq2);
			
			Assert.AreEqual(boost, filteredquery.GetBoost(), 0);
			Assert.AreEqual(1.0f, tq.GetBoost(), 0); // the boost value of the underlying query shouldn't have changed 
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:49,代码来源:TestFilteredQuery.cs


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