diff --git a/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java index 3c89dfd6291..36410b9a099 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java @@ -31,7 +31,7 @@ public class SpanNearQueryBuilder extends BaseQueryBuilder implements SpanQueryB private ArrayList clauses = new ArrayList(); - private int slop = -1; + private Integer slop = null; private Boolean inOrder; @@ -79,7 +79,7 @@ public class SpanNearQueryBuilder extends BaseQueryBuilder implements SpanQueryB if (clauses.isEmpty()) { throw new QueryBuilderException("Must have at least one clause when building a spanNear query"); } - if (slop == -1) { + if (slop == null) { throw new QueryBuilderException("Must set the slop when building a spanNear query"); } builder.startObject(SpanNearQueryParser.NAME); @@ -88,7 +88,7 @@ public class SpanNearQueryBuilder extends BaseQueryBuilder implements SpanQueryB clause.toXContent(builder, params); } builder.endArray(); - builder.field("slop", slop); + builder.field("slop", slop.intValue()); if (inOrder != null) { builder.field("in_order", inOrder); }