Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to fix #3079 (span_near query should accept slop = -1) #3122

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -52,7 +52,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
XContentParser parser = parseContext.parser();

float boost = 1.0f;
int slop = -1;
Integer slop = null;
boolean inOrder = true;
boolean collectPayloads = true;

Expand Down Expand Up @@ -81,7 +81,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
} 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 {
Expand All @@ -94,12 +94,12 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
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;
}
}
}