Search in sources :

Example 1 with SpanContainingQuery

use of org.apache.lucene.search.spans.SpanContainingQuery in project elasticsearch by elastic.

the class SpanContainingQueryBuilder method doToQuery.

@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
    Query innerBig = big.toQuery(context);
    assert innerBig instanceof SpanQuery;
    Query innerLittle = little.toQuery(context);
    assert innerLittle instanceof SpanQuery;
    return new SpanContainingQuery((SpanQuery) innerBig, (SpanQuery) innerLittle);
}
Also used : Query(org.apache.lucene.search.Query) SpanContainingQuery(org.apache.lucene.search.spans.SpanContainingQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) SpanContainingQuery(org.apache.lucene.search.spans.SpanContainingQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery)

Example 2 with SpanContainingQuery

use of org.apache.lucene.search.spans.SpanContainingQuery in project lucene-solr by apache.

the class TestPayloadScoreQuery method testSpanContainingQuery.

@Test
public void testSpanContainingQuery() throws Exception {
    // twenty WITHIN ((one OR hundred) NEAR two)~2
    SpanContainingQuery q = new SpanContainingQuery(new SpanNearQuery(new SpanQuery[] { new SpanOrQuery(new SpanTermQuery(new Term("field", "one")), new SpanTermQuery(new Term("field", "hundred"))), new SpanTermQuery(new Term("field", "two")) }, 2, true), new SpanTermQuery(new Term("field", "twenty")));
    checkQuery(q, new AveragePayloadFunction(), new int[] { 222, 122 }, new float[] { 4.0f, 3.666666f });
    checkQuery(q, new MaxPayloadFunction(), new int[] { 122, 222 }, new float[] { 4.0f, 4.0f });
    checkQuery(q, new MinPayloadFunction(), new int[] { 222, 122 }, new float[] { 4.0f, 2.0f });
}
Also used : SpanContainingQuery(org.apache.lucene.search.spans.SpanContainingQuery) SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) Term(org.apache.lucene.index.Term) SpanOrQuery(org.apache.lucene.search.spans.SpanOrQuery) SpanNearQuery(org.apache.lucene.search.spans.SpanNearQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) Test(org.junit.Test)

Aggregations

SpanContainingQuery (org.apache.lucene.search.spans.SpanContainingQuery)2 SpanQuery (org.apache.lucene.search.spans.SpanQuery)2 Term (org.apache.lucene.index.Term)1 Query (org.apache.lucene.search.Query)1 SpanNearQuery (org.apache.lucene.search.spans.SpanNearQuery)1 SpanOrQuery (org.apache.lucene.search.spans.SpanOrQuery)1 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)1 Test (org.junit.Test)1