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:
iksnalybok 2013-05-30 22:49:09 +02:00 committed by Simon Willnauer
parent 663f653ced
commit 47154a79c5
1 changed files with 5 additions and 5 deletions

View File

@ -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;
}
}
}