Search in sources :

Example 1 with NormValueSource

use of org.apache.lucene.queries.function.valuesource.NormValueSource in project lucene-solr by apache.

the class TestValueSources method testNorm.

public void testNorm() throws Exception {
    Similarity saved = searcher.getSimilarity(true);
    try {
        // no norm field (so agnostic to indexed similarity)
        searcher.setSimilarity(new ClassicSimilarity());
        ValueSource vs = new NormValueSource("byte");
        assertHits(new FunctionQuery(vs), new float[] { 1f, 1f });
        // regardless of whether norms exist, value source exists == 0
        assertAllExist(vs);
        vs = new NormValueSource("text");
        assertAllExist(vs);
    } finally {
        searcher.setSimilarity(saved);
    }
}
Also used : ClassicSimilarity(org.apache.lucene.search.similarities.ClassicSimilarity) ClassicSimilarity(org.apache.lucene.search.similarities.ClassicSimilarity) Similarity(org.apache.lucene.search.similarities.Similarity) SumTotalTermFreqValueSource(org.apache.lucene.queries.function.valuesource.SumTotalTermFreqValueSource) DoubleConstValueSource(org.apache.lucene.queries.function.valuesource.DoubleConstValueSource) ConstValueSource(org.apache.lucene.queries.function.valuesource.ConstValueSource) QueryValueSource(org.apache.lucene.queries.function.valuesource.QueryValueSource) DocFreqValueSource(org.apache.lucene.queries.function.valuesource.DocFreqValueSource) NormValueSource(org.apache.lucene.queries.function.valuesource.NormValueSource) NumDocsValueSource(org.apache.lucene.queries.function.valuesource.NumDocsValueSource) MaxDocValueSource(org.apache.lucene.queries.function.valuesource.MaxDocValueSource) JoinDocFreqValueSource(org.apache.lucene.queries.function.valuesource.JoinDocFreqValueSource) LiteralValueSource(org.apache.lucene.queries.function.valuesource.LiteralValueSource) TotalTermFreqValueSource(org.apache.lucene.queries.function.valuesource.TotalTermFreqValueSource) IDFValueSource(org.apache.lucene.queries.function.valuesource.IDFValueSource) TermFreqValueSource(org.apache.lucene.queries.function.valuesource.TermFreqValueSource) TFValueSource(org.apache.lucene.queries.function.valuesource.TFValueSource) NormValueSource(org.apache.lucene.queries.function.valuesource.NormValueSource)

Example 2 with NormValueSource

use of org.apache.lucene.queries.function.valuesource.NormValueSource in project lucene-solr by apache.

the class TestLongNormValueSource method testNorm.

public void testNorm() throws Exception {
    Similarity saved = searcher.getSimilarity(true);
    try {
        // no norm field (so agnostic to indexed similarity)
        searcher.setSimilarity(sim);
        assertHits(new FunctionQuery(new NormValueSource("text")), new float[] { 0f, 0f });
    } finally {
        searcher.setSimilarity(saved);
    }
}
Also used : ClassicSimilarity(org.apache.lucene.search.similarities.ClassicSimilarity) Similarity(org.apache.lucene.search.similarities.Similarity) NormValueSource(org.apache.lucene.queries.function.valuesource.NormValueSource)

Aggregations

NormValueSource (org.apache.lucene.queries.function.valuesource.NormValueSource)2 ClassicSimilarity (org.apache.lucene.search.similarities.ClassicSimilarity)2 Similarity (org.apache.lucene.search.similarities.Similarity)2 ConstValueSource (org.apache.lucene.queries.function.valuesource.ConstValueSource)1 DocFreqValueSource (org.apache.lucene.queries.function.valuesource.DocFreqValueSource)1 DoubleConstValueSource (org.apache.lucene.queries.function.valuesource.DoubleConstValueSource)1 IDFValueSource (org.apache.lucene.queries.function.valuesource.IDFValueSource)1 JoinDocFreqValueSource (org.apache.lucene.queries.function.valuesource.JoinDocFreqValueSource)1 LiteralValueSource (org.apache.lucene.queries.function.valuesource.LiteralValueSource)1 MaxDocValueSource (org.apache.lucene.queries.function.valuesource.MaxDocValueSource)1 NumDocsValueSource (org.apache.lucene.queries.function.valuesource.NumDocsValueSource)1 QueryValueSource (org.apache.lucene.queries.function.valuesource.QueryValueSource)1 SumTotalTermFreqValueSource (org.apache.lucene.queries.function.valuesource.SumTotalTermFreqValueSource)1 TFValueSource (org.apache.lucene.queries.function.valuesource.TFValueSource)1 TermFreqValueSource (org.apache.lucene.queries.function.valuesource.TermFreqValueSource)1 TotalTermFreqValueSource (org.apache.lucene.queries.function.valuesource.TotalTermFreqValueSource)1