CreateWeight() public method

public CreateWeight ( Searcher searcher ) : Weight
searcher Searcher
return Weight
コード例 #1
0
        public virtual void TestCustomIDF()
        {
            Directory         indexStore = NewDirectory();
            RandomIndexWriter writer     = new RandomIndexWriter(Random(), indexStore);

            Add("this is a test", "object", writer);
            Add("a note", "note", writer);

            IndexReader   reader   = writer.Reader;
            IndexSearcher searcher = NewSearcher(reader);

            searcher.Similarity = new DefaultSimilarityAnonymousInnerClassHelper(this);

            MultiPhraseQuery query = new MultiPhraseQuery();

            query.Add(new Term[] { new Term("body", "this"), new Term("body", "that") });
            query.Add(new Term("body", "is"));
            Weight weight = query.CreateWeight(searcher);

            Assert.AreEqual(10f * 10f, weight.ValueForNormalization, 0.001f);

            writer.Dispose();
            reader.Dispose();
            indexStore.Dispose();
        }
コード例 #2
0
        public virtual void TestCustomIDF()
        {
            Directory         indexStore = NewDirectory();
            RandomIndexWriter writer     = new RandomIndexWriter(
#if FEATURE_INSTANCE_TESTDATA_INITIALIZATION
                this,
#endif
                Random, indexStore);

            Add("this is a test", "object", writer);
            Add("a note", "note", writer);

            IndexReader   reader   = writer.GetReader();
            IndexSearcher searcher = NewSearcher(reader);

            searcher.Similarity = new DefaultSimilarityAnonymousClass(this);

            MultiPhraseQuery query = new MultiPhraseQuery();

            query.Add(new Term[] { new Term("body", "this"), new Term("body", "that") });
            query.Add(new Term("body", "is"));
            Weight weight = query.CreateWeight(searcher);

            Assert.AreEqual(10f * 10f, weight.GetValueForNormalization(), 0.001f);

            writer.Dispose();
            reader.Dispose();
            indexStore.Dispose();
        }
コード例 #3
0
        public virtual void TestCustomIDF()
        {
            Directory indexStore = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), indexStore, Similarity, TimeZone);
            Add("this is a test", "object", writer);
            Add("a note", "note", writer);

            IndexReader reader = writer.Reader;
            IndexSearcher searcher = NewSearcher(reader);
            searcher.Similarity = new DefaultSimilarityAnonymousInnerClassHelper(this);

            MultiPhraseQuery query = new MultiPhraseQuery();
            query.Add(new Term[] { new Term("body", "this"), new Term("body", "that") });
            query.Add(new Term("body", "is"));
            Weight weight = query.CreateWeight(searcher);
            Assert.AreEqual(10f * 10f, weight.ValueForNormalization, 0.001f);

            writer.Dispose();
            reader.Dispose();
            indexStore.Dispose();
        }