Add `field_masking_span` to IndexQueryModule
The query parser for `field_masking_span` has never been added / bound to the IndexQueryModule. Closes #3007
This commit is contained in:
parent
32abf6b890
commit
992a40cbd8
|
@ -92,6 +92,7 @@ public class IndicesQueriesModule extends AbstractModule {
|
|||
qpBinders.addBinding().to(CustomFiltersScoreQueryParser.class).asEagerSingleton();
|
||||
qpBinders.addBinding().to(SpanTermQueryParser.class).asEagerSingleton();
|
||||
qpBinders.addBinding().to(SpanNotQueryParser.class).asEagerSingleton();
|
||||
qpBinders.addBinding().to(FieldMaskingSpanQueryParser.class).asEagerSingleton();
|
||||
qpBinders.addBinding().to(SpanFirstQueryParser.class).asEagerSingleton();
|
||||
qpBinders.addBinding().to(SpanNearQueryParser.class).asEagerSingleton();
|
||||
qpBinders.addBinding().to(SpanOrQueryParser.class).asEagerSingleton();
|
||||
|
|
|
@ -1538,6 +1538,22 @@ public class SimpleIndexQueryParserTests {
|
|||
assertThat(((SpanTermQuery) spanNearQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36, 0))));
|
||||
assertThat(spanNearQuery.isInOrder(), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFieldMaskingSpanQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/spanFieldMaskingTerm.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(SpanNearQuery.class));
|
||||
SpanNearQuery spanNearQuery = (SpanNearQuery) parsedQuery;
|
||||
assertThat(spanNearQuery.getClauses().length, equalTo(3));
|
||||
assertThat(((SpanTermQuery) spanNearQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0))));
|
||||
assertThat(((SpanTermQuery) spanNearQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0))));
|
||||
assertThat(((SpanTermQuery)((FieldMaskingSpanQuery) spanNearQuery.getClauses()[2]).getMaskedQuery()).getTerm(), equalTo(new Term("age_1", "36")));
|
||||
assertThat(spanNearQuery.isInOrder(), equalTo(false));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSpanOrQueryBuilder() throws IOException {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
span_near:{
|
||||
clauses:[
|
||||
{
|
||||
span_term:{
|
||||
age:34
|
||||
}
|
||||
},
|
||||
{
|
||||
span_term:{
|
||||
age:35
|
||||
}
|
||||
},
|
||||
{
|
||||
field_masking_span:{
|
||||
query:{
|
||||
span_term:{
|
||||
age_1 : 36
|
||||
}
|
||||
},
|
||||
field:"age"
|
||||
}
|
||||
}
|
||||
],
|
||||
slop:12,
|
||||
in_order:false,
|
||||
collect_payloads:false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue