Search in sources :

Example 6 with ConstValueSource

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

the class TestValueSources method testReciprocal.

public void testReciprocal() throws Exception {
    ValueSource vs = new ReciprocalFloatFunction(new ConstValueSource(2f), 3, 1, 4);
    assertHits(new FunctionQuery(vs), new float[] { 0.1f, 0.1f });
    assertAllExist(vs);
    vs = new ReciprocalFloatFunction(BOGUS_FLOAT_VS, 3, 1, 4);
    assertNoneExist(vs);
}
Also used : 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) ReciprocalFloatFunction(org.apache.lucene.queries.function.valuesource.ReciprocalFloatFunction) DoubleConstValueSource(org.apache.lucene.queries.function.valuesource.DoubleConstValueSource) ConstValueSource(org.apache.lucene.queries.function.valuesource.ConstValueSource)

Example 7 with ConstValueSource

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

the class TestValueSources method testMinFloat.

public void testMinFloat() throws Exception {
    ValueSource vs = new MinFloatFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) });
    assertHits(new FunctionQuery(vs), new float[] { 1f, 1f });
    assertAllExist(vs);
    // as long as one value exists, then min exists
    vs = new MinFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, new ConstValueSource(2F) });
    assertHits(new FunctionQuery(vs), new float[] { 2F, 2F });
    assertAllExist(vs);
    vs = new MinFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, new ConstValueSource(2F), BOGUS_DOUBLE_VS });
    assertAllExist(vs);
    // if none exist, then min doesn't exist
    vs = new MinFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, BOGUS_INT_VS, BOGUS_DOUBLE_VS });
    assertNoneExist(vs);
}
Also used : 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) MinFloatFunction(org.apache.lucene.queries.function.valuesource.MinFloatFunction) DoubleConstValueSource(org.apache.lucene.queries.function.valuesource.DoubleConstValueSource) ConstValueSource(org.apache.lucene.queries.function.valuesource.ConstValueSource)

Example 8 with ConstValueSource

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

the class TestValueSources method testPow.

public void testPow() throws Exception {
    ValueSource vs = new PowFloatFunction(new ConstValueSource(2f), new ConstValueSource(3f));
    assertHits(new FunctionQuery(vs), new float[] { 8f, 8f });
    assertAllExist(vs);
    vs = new PowFloatFunction(BOGUS_FLOAT_VS, new ConstValueSource(3f));
    assertNoneExist(vs);
    vs = new PowFloatFunction(new ConstValueSource(3f), BOGUS_FLOAT_VS);
    assertNoneExist(vs);
}
Also used : 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) DoubleConstValueSource(org.apache.lucene.queries.function.valuesource.DoubleConstValueSource) ConstValueSource(org.apache.lucene.queries.function.valuesource.ConstValueSource) PowFloatFunction(org.apache.lucene.queries.function.valuesource.PowFloatFunction)

Example 9 with ConstValueSource

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

the class TestValueSources method testConst.

public void testConst() throws Exception {
    ValueSource vs = new ConstValueSource(0.3f);
    assertHits(new FunctionQuery(vs), new float[] { 0.3f, 0.3f });
    assertAllExist(vs);
}
Also used : 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) DoubleConstValueSource(org.apache.lucene.queries.function.valuesource.DoubleConstValueSource) ConstValueSource(org.apache.lucene.queries.function.valuesource.ConstValueSource)

Example 10 with ConstValueSource

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

the class TestFunctionQueryExplanations method testBoost.

public void testBoost() throws Exception {
    Query q = new BoostQuery(new FunctionQuery(new ConstValueSource(5)), 2);
    qtest(q, new int[] { 0, 1, 2, 3 });
}
Also used : Query(org.apache.lucene.search.Query) BoostQuery(org.apache.lucene.search.BoostQuery) ConstValueSource(org.apache.lucene.queries.function.valuesource.ConstValueSource) BoostQuery(org.apache.lucene.search.BoostQuery)

Aggregations

ConstValueSource (org.apache.lucene.queries.function.valuesource.ConstValueSource)20 DocFreqValueSource (org.apache.lucene.queries.function.valuesource.DocFreqValueSource)12 DoubleConstValueSource (org.apache.lucene.queries.function.valuesource.DoubleConstValueSource)12 IDFValueSource (org.apache.lucene.queries.function.valuesource.IDFValueSource)12 JoinDocFreqValueSource (org.apache.lucene.queries.function.valuesource.JoinDocFreqValueSource)12 LiteralValueSource (org.apache.lucene.queries.function.valuesource.LiteralValueSource)12 MaxDocValueSource (org.apache.lucene.queries.function.valuesource.MaxDocValueSource)12 NormValueSource (org.apache.lucene.queries.function.valuesource.NormValueSource)12 NumDocsValueSource (org.apache.lucene.queries.function.valuesource.NumDocsValueSource)12 QueryValueSource (org.apache.lucene.queries.function.valuesource.QueryValueSource)12 SumTotalTermFreqValueSource (org.apache.lucene.queries.function.valuesource.SumTotalTermFreqValueSource)12 TFValueSource (org.apache.lucene.queries.function.valuesource.TFValueSource)12 TermFreqValueSource (org.apache.lucene.queries.function.valuesource.TermFreqValueSource)12 TotalTermFreqValueSource (org.apache.lucene.queries.function.valuesource.TotalTermFreqValueSource)12 Query (org.apache.lucene.search.Query)8 BoostQuery (org.apache.lucene.search.BoostQuery)7 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)5 FunctionQuery (org.apache.lucene.queries.function.FunctionQuery)4 BooleanQuery (org.apache.lucene.search.BooleanQuery)4 TermQuery (org.apache.lucene.search.TermQuery)4