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


C# Lucene.Net.Documents.Document.SetBoost方法代码示例

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


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

示例1: TestDocBoost_

		public virtual void  TestDocBoost_()
		{
			RAMDirectory store = new RAMDirectory();
			IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true);
			
			Field f1 = Field.Text("Field", "word");
			Field f2 = Field.Text("Field", "word");
			f2.SetBoost(2.0f);
			
			Document d1 = new Document();
			Document d2 = new Document();
			Document d3 = new Document();
			Document d4 = new Document();
			d3.SetBoost(3.0f);
			d4.SetBoost(2.0f);
			
			d1.Add(f1); // boost = 1
			d2.Add(f2); // boost = 2
			d3.Add(f1); // boost = 3
			d4.Add(f2); // boost = 4
			
			writer.AddDocument(d1);
			writer.AddDocument(d2);
			writer.AddDocument(d3);
			writer.AddDocument(d4);
			writer.Optimize();
			writer.Close();
			
			float[] scores = new float[4];
			
			new IndexSearcher(store).Search(new TermQuery(new Term("Field", "word")), new AnonymousClassHitCollector(scores, this));
			
			float lastScore = 0.0f;
			
			for (int i = 0; i < 4; i++)
			{
				Assert.IsTrue(scores[i] > lastScore);
				lastScore = scores[i];
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:40,代码来源:TestDocBoost.cs

示例2: GetFullStrings

		private IndexSearcher GetFullStrings()
		{
			RAMDirectory indexStore = new RAMDirectory();
			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			writer.SetMaxBufferedDocs(4);
			writer.SetMergeFactor(97);
			for (int i = 0; i < NUM_STRINGS; i++)
			{
				Document doc = new Document();
				System.String num = GetRandomCharString(GetRandomNumber(2, 8), 48, 52);
				doc.Add(new Field("tracer", num, Field.Store.YES, Field.Index.NO));
				//doc.add (new Field ("contents", Integer.toString(i), Field.Store.NO, Field.Index.ANALYZED));
				doc.Add(new Field("string", num, Field.Store.NO, Field.Index.NOT_ANALYZED));
				System.String num2 = GetRandomCharString(GetRandomNumber(1, 4), 48, 50);
				doc.Add(new Field("string2", num2, Field.Store.NO, Field.Index.NOT_ANALYZED));
				doc.Add(new Field("tracer2", num2, Field.Store.YES, Field.Index.NO));
				doc.SetBoost(2); // produce some scores above 1.0
				writer.SetMaxBufferedDocs(GetRandomNumber(2, 12));
				writer.AddDocument(doc);
			}
			//writer.optimize ();
			//System.out.println(writer.getSegmentCount());
			writer.Close();
			return new IndexSearcher(indexStore);
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:25,代码来源:TestSort.cs

示例3: GetIndex

		// create an index of all the documents, or just the x, or just the y documents
		private Searcher GetIndex(bool even, bool odd)
		{
			RAMDirectory indexStore = new RAMDirectory();
			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			writer.SetMaxBufferedDocs(2);
			writer.SetMergeFactor(1000);
			for (int i = 0; i < data.Length; ++i)
			{
				if (((i % 2) == 0 && even) || ((i % 2) == 1 && odd))
				{
					Document doc = new Document();
					doc.Add(new Field("tracer", data[i][0], Field.Store.YES, Field.Index.NO));
					doc.Add(new Field("contents", data[i][1], Field.Store.NO, Field.Index.ANALYZED));
					if (data[i][2] != null)
						doc.Add(new Field("int", data[i][2], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][3] != null)
						doc.Add(new Field("float", data[i][3], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][4] != null)
						doc.Add(new Field("string", data[i][4], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][5] != null)
						doc.Add(new Field("custom", data[i][5], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][6] != null)
						doc.Add(new Field("i18n", data[i][6], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][7] != null)
						doc.Add(new Field("long", data[i][7], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][8] != null)
						doc.Add(new Field("double", data[i][8], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][9] != null)
						doc.Add(new Field("short", data[i][9], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][10] != null)
						doc.Add(new Field("byte", data[i][10], Field.Store.NO, Field.Index.NOT_ANALYZED));
					if (data[i][11] != null)
						doc.Add(new Field("parser", data[i][11], Field.Store.NO, Field.Index.NOT_ANALYZED));
					doc.SetBoost(2); // produce some scores above 1.0
					writer.AddDocument(doc);
				}
			}
			//writer.optimize ();
			writer.Close();
			IndexSearcher s = new IndexSearcher(indexStore);
			s.SetDefaultFieldSortScoring(true, true);
			return s;
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:44,代码来源:TestSort.cs


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