use of org.apache.lucene.queries.intervals.IntervalQuery in project OpenSearch by opensearch-project.
the class IntervalQueryBuilderTests method testOrInterval.
public void testOrInterval() throws IOException {
String json = "{ \"intervals\" : { \"" + TEXT_FIELD_NAME + "\": {" + " \"any_of\" : { " + " \"intervals\" : [" + " { \"match\" : { \"query\" : \"one\" } }," + " { \"match\" : { \"query\" : \"two\" } } ] } } } }";
IntervalQueryBuilder builder = (IntervalQueryBuilder) parseQuery(json);
Query expected = new IntervalQuery(TEXT_FIELD_NAME, Intervals.or(Intervals.term("one"), Intervals.term("two")));
assertEquals(expected, builder.toQuery(createShardContext()));
json = "{ \"intervals\" : { \"" + TEXT_FIELD_NAME + "\": {" + " \"any_of\" : { " + " \"intervals\" : [" + " { \"match\" : { \"query\" : \"one\" } }," + " { \"match\" : { \"query\" : \"two\" } } ]," + " \"filter\" : {" + " \"not_containing\" : { \"match\" : { \"query\" : \"three\" } } } } } } }";
builder = (IntervalQueryBuilder) parseQuery(json);
expected = new IntervalQuery(TEXT_FIELD_NAME, Intervals.notContaining(Intervals.or(Intervals.term("one"), Intervals.term("two")), Intervals.term("three")));
assertEquals(expected, builder.toQuery(createShardContext()));
}
Aggregations