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


C# IndexWriter.SetSimilarity方法代码示例

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


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

示例1: CreateIndexWriter

        const int MaxMergeDocs = 7999;     //  Except never merge segments that have more docs than this

        public static IndexWriter CreateIndexWriter(Lucene.Net.Store.Directory directory, bool create)
        {
            IndexWriter indexWriter = new IndexWriter(directory, new PackageAnalyzer(), create, IndexWriter.MaxFieldLength.UNLIMITED);
            indexWriter.MergeFactor = MergeFactor;
            indexWriter.MaxMergeDocs = MaxMergeDocs;

            indexWriter.SetSimilarity(new CustomSimilarity());
            return indexWriter;
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:11,代码来源:DocumentCreator.cs

示例2: AddDocs

		private void  AddDocs(Directory dir, int ndocs, bool compound)
		{
			IndexWriter iw = new IndexWriter(dir, anlzr, false, IndexWriter.MaxFieldLength.LIMITED);
			iw.SetMaxBufferedDocs(5);
			iw.SetMergeFactor(3);
			iw.SetSimilarity(similarityOne);
			iw.SetUseCompoundFile(compound);
			for (int i = 0; i < ndocs; i++)
			{
				iw.AddDocument(NewDoc());
			}
			iw.Close();
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:13,代码来源:TestNorms.cs

示例3: CreateIndex

		private void  CreateIndex(Directory dir)
		{
			IndexWriter iw = new IndexWriter(dir, anlzr, true, IndexWriter.MaxFieldLength.LIMITED);
			iw.SetMaxBufferedDocs(5);
			iw.SetMergeFactor(3);
			iw.SetSimilarity(similarityOne);
			iw.SetUseCompoundFile(true);
			iw.Close();
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:9,代码来源:TestNorms.cs

示例4: TestBasic

 public virtual void  TestBasic()
 {
     Directory dir = new MockRAMDirectory();
     Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
     IndexWriter writer = new IndexWriter(dir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
     writer.MergeFactor = 2;
     writer.SetMaxBufferedDocs(2);
     writer.SetSimilarity(new SimpleSimilarity());
     
     
     System.Text.StringBuilder sb = new System.Text.StringBuilder(265);
     System.String term = "term";
     for (int i = 0; i < 30; i++)
     {
         Document d = new Document();
         sb.Append(term).Append(" ");
         System.String content = sb.ToString();
         Field noTf = new Field("noTf", content + (i % 2 == 0?"":" notf"), Field.Store.NO, Field.Index.ANALYZED);
         noTf.OmitTermFreqAndPositions = true;
         d.Add(noTf);
         
         Field tf = new Field("tf", content + (i % 2 == 0?" tf":""), Field.Store.NO, Field.Index.ANALYZED);
         d.Add(tf);
         
         writer.AddDocument(d);
         //System.out.println(d);
     }
     
     writer.Optimize();
     // flush
     writer.Close();
     _TestUtil.CheckIndex(dir);
     
     /*
     * Verify the index
     */
     Searcher searcher = new IndexSearcher(dir, true);
     searcher.Similarity = new SimpleSimilarity();
     
     Term a = new Term("noTf", term);
     Term b = new Term("tf", term);
     Term c = new Term("noTf", "notf");
     Term d2 = new Term("tf", "tf");
     TermQuery q1 = new TermQuery(a);
     TermQuery q2 = new TermQuery(b);
     TermQuery q3 = new TermQuery(c);
     TermQuery q4 = new TermQuery(d2);
     
     
     searcher.Search(q1, new AnonymousClassCountingHitCollector(this));
     //System.out.println(CountingHitCollector.getCount());
     
     
     searcher.Search(q2, new AnonymousClassCountingHitCollector1(this));
     //System.out.println(CountingHitCollector.getCount());
     
     
     
     
     
     searcher.Search(q3, new AnonymousClassCountingHitCollector2(this));
     //System.out.println(CountingHitCollector.getCount());
     
     
     searcher.Search(q4, new AnonymousClassCountingHitCollector3(this));
     //System.out.println(CountingHitCollector.getCount());
     
     
     
     BooleanQuery bq = new BooleanQuery();
     bq.Add(q1, Occur.MUST);
     bq.Add(q4, Occur.MUST);
     
     searcher.Search(bq, new AnonymousClassCountingHitCollector4(this));
     Assert.IsTrue(15 == CountingHitCollector.GetCount());
     
     searcher.Close();
     dir.Close();
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:79,代码来源:TestOmitTf.cs

示例5: WriteDoc

		/// <summary> Writes the document to the directory using the analyzer
		/// and the similarity score; returns the SegmentInfo
		/// describing the new segment
		/// </summary>
		/// <param name="dir">
		/// </param>
		/// <param name="analyzer">
		/// </param>
		/// <param name="similarity">
		/// </param>
		/// <param name="doc">
		/// </param>
		/// <throws>  IOException </throws>
		public static SegmentInfo WriteDoc(Directory dir, Analyzer analyzer, Similarity similarity, Document doc)
		{
			IndexWriter writer = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.LIMITED);
			writer.SetSimilarity(similarity);
			//writer.setUseCompoundFile(false);
			writer.AddDocument(doc);
			writer.Flush();
			SegmentInfo info = writer.NewestSegment();
			writer.Close();
			return info;
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:24,代码来源:DocHelper.cs

示例6: CreateIndexWriter

        internal static IndexWriter CreateIndexWriter(Lucene.Net.Store.Directory directory)
        {
            bool create = !IndexReader.IndexExists(directory);

            directory.EnsureOpen();

            if (!create)
            {
                if (IndexWriter.IsLocked(directory))
                {
                    IndexWriter.Unlock(directory);
                }
            }

            IndexWriter indexWriter = new IndexWriter(directory, new PackageAnalyzer(), create, IndexWriter.MaxFieldLength.UNLIMITED);
            indexWriter.MergeFactor = MergeFactor;
            indexWriter.MaxMergeDocs = MaxMergeDocs;

            indexWriter.SetSimilarity(new CustomSimilarity());

            return indexWriter;
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:22,代码来源:SearchIndexFromCatalogCollector.cs

示例7: CreateIndexWriter

        private static IndexWriter CreateIndexWriter(Lucene.Net.Store.Directory directory)
        {
            var create = !IndexReader.IndexExists(directory);

            directory.EnsureOpen();

            if (!create)
            {
                if (IndexWriter.IsLocked(directory))
                {
                    IndexWriter.Unlock(directory);
                }
            }

            var indexWriter = new IndexWriter(directory, new PackageAnalyzer(), create, IndexWriter.MaxFieldLength.UNLIMITED);

            NuGetMergePolicyApplyer.ApplyTo(indexWriter);

            indexWriter.SetSimilarity(new CustomSimilarity());

            return indexWriter;
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:22,代码来源:Catalog2LuceneJob.cs


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