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);
}
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 });
}
Aggregations