Query DSL: Span Term Query wrongly parses when boost is provided, causing using it in span or to fail, closes #1032.
This commit is contained in:
parent
551b98f2f8
commit
11f19ff6da
|
@ -74,6 +74,7 @@ public class SpanTermQueryParser implements QueryParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
parser.nextToken();
|
||||||
} else {
|
} else {
|
||||||
value = parser.text();
|
value = parser.text();
|
||||||
// move to the next token
|
// move to the next token
|
||||||
|
|
|
@ -1223,6 +1223,18 @@ public class SimpleIndexQueryParserTests {
|
||||||
assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36))));
|
assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test public void testSpanOrQuery2() throws IOException {
|
||||||
|
IndexQueryParserService queryParser = queryParser();
|
||||||
|
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/spanOr2.json");
|
||||||
|
Query parsedQuery = queryParser.parse(query).query();
|
||||||
|
assertThat(parsedQuery, instanceOf(SpanOrQuery.class));
|
||||||
|
SpanOrQuery spanOrQuery = (SpanOrQuery) parsedQuery;
|
||||||
|
assertThat(spanOrQuery.getClauses().length, equalTo(3));
|
||||||
|
assertThat(((SpanTermQuery) spanOrQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(34))));
|
||||||
|
assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35))));
|
||||||
|
assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36))));
|
||||||
|
}
|
||||||
|
|
||||||
@Test public void testQueryFilterBuilder() throws Exception {
|
@Test public void testQueryFilterBuilder() throws Exception {
|
||||||
IndexQueryParserService queryParser = queryParser();
|
IndexQueryParserService queryParser = queryParser();
|
||||||
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), queryFilter(termQuery("name.last", "banon")))).query();
|
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), queryFilter(termQuery("name.last", "banon")))).query();
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"span_or" : {
|
||||||
|
"clauses" : [
|
||||||
|
{
|
||||||
|
"span_term" : {
|
||||||
|
"age" : {
|
||||||
|
"value" : 34,
|
||||||
|
"boost" : 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"span_term" : {
|
||||||
|
"age" : {
|
||||||
|
"value" : 35,
|
||||||
|
"boost" : 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"span_term" : {
|
||||||
|
"age" : {
|
||||||
|
"value" : 36,
|
||||||
|
"boost" : 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue