Allow negative slops in SpanNearQueryParser
This is mainly due to the fact that SpanNearQuery allows some neat tricks with negative slops to run zero-sloped near queries across 2 or more SpanTermQueries. Closes #3079
This commit is contained in:
parent
663f653ced
commit
47154a79c5
|
@ -52,7 +52,7 @@ public class SpanNearQueryParser implements QueryParser {
|
|||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = 1.0f;
|
||||
int slop = -1;
|
||||
Integer slop = null;
|
||||
boolean inOrder = true;
|
||||
boolean collectPayloads = true;
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class SpanNearQueryParser implements QueryParser {
|
|||
} else if ("collect_payloads".equals(currentFieldName) || "collectPayloads".equals(currentFieldName)) {
|
||||
collectPayloads = parser.booleanValue();
|
||||
} else if ("slop".equals(currentFieldName)) {
|
||||
slop = parser.intValue();
|
||||
slop = Integer.valueOf(parser.intValue());
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
|
@ -94,12 +94,12 @@ public class SpanNearQueryParser implements QueryParser {
|
|||
if (clauses.isEmpty()) {
|
||||
throw new QueryParsingException(parseContext.index(), "span_near must include [clauses]");
|
||||
}
|
||||
if (slop == -1) {
|
||||
if (slop == null) {
|
||||
throw new QueryParsingException(parseContext.index(), "span_near must include [slop]");
|
||||
}
|
||||
|
||||
SpanNearQuery query = new SpanNearQuery(clauses.toArray(new SpanQuery[clauses.size()]), slop, inOrder, collectPayloads);
|
||||
SpanNearQuery query = new SpanNearQuery(clauses.toArray(new SpanQuery[clauses.size()]), slop.intValue(), inOrder, collectPayloads);
|
||||
query.setBoost(boost);
|
||||
return query;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue