From 47154a79c5d25e7dd5527638b0be79deff447a3a Mon Sep 17 00:00:00 2001 From: iksnalybok Date: Thu, 30 May 2013 22:49:09 +0200 Subject: [PATCH] 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 --- .../elasticsearch/index/query/SpanNearQueryParser.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java b/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java index 2022f084967..c0e69d32d55 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java @@ -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; } -} \ No newline at end of file +}