diff --git a/pom.xml b/pom.xml
index c492dd8d0f5d..d96142d331fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
org.elasticsearch
elasticsearch
- 1.4.1-rest-1.0.27-SNAPSHOT
+ 1.4.1-rest-1.0.28-SNAPSHOT
jar
Elasticsearch - Open Source, Distributed, RESTful Search Engine
2009
diff --git a/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java
index 179cea860e43..add45dbb1201 100644
--- a/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java
+++ b/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java
@@ -19,7 +19,9 @@
package org.elasticsearch.index.query;
+import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable;
+import org.elasticsearch.common.xcontent.ToXContentUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
@@ -73,7 +75,11 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
queryBuilder.toXContent(builder, params);
}
if (filterBuilder != null) {
- builder.field("filter");
+ if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
+ builder.field("query");
+ } else {
+ builder.field("filter");
+ }
filterBuilder.toXContent(builder, params);
}
if (boost != -1) {
diff --git a/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java
index 68e2eba2626f..7784854069bf 100644
--- a/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java
+++ b/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java
@@ -19,6 +19,8 @@
package org.elasticsearch.index.query;
+import org.elasticsearch.Version;
+import org.elasticsearch.common.xcontent.ToXContentUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
@@ -68,17 +70,21 @@ public MissingFilterBuilder filterName(String filterName) {
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
- builder.startObject(MissingFilterParser.NAME);
- builder.field("field", name);
- if (nullValue != null) {
- builder.field("null_value", nullValue);
+ if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
+ FilterBuilders.boolFilter().mustNot(FilterBuilders.existsFilter(name).filterName(filterName)).doXContent(builder, params);
+ } else {
+ builder.startObject(MissingFilterParser.NAME);
+ builder.field("field", name);
+ if (nullValue != null) {
+ builder.field("null_value", nullValue);
+ }
+ if (existence != null) {
+ builder.field("existence", existence);
+ }
+ if (filterName != null) {
+ builder.field("_name", filterName);
+ }
+ builder.endObject();
}
- if (existence != null) {
- builder.field("existence", existence);
- }
- if (filterName != null) {
- builder.field("_name", filterName);
- }
- builder.endObject();
}
}
diff --git a/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java
index 8e86f1ff4ce2..8dbb2081d4c6 100644
--- a/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java
+++ b/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java
@@ -19,6 +19,8 @@
package org.elasticsearch.index.query;
+import org.elasticsearch.Version;
+import org.elasticsearch.common.xcontent.ToXContentUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
@@ -80,22 +82,29 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.field("query");
queryBuilder.toXContent(builder, params);
} else {
- builder.field("filter");
+ if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
+ builder.field("query");
+ } else {
+ builder.field("filter");
+ }
filterBuilder.toXContent(builder, params);
}
- if (join != null) {
- builder.field("join", join);
+
+ if (!ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
+ if (join != null) {
+ builder.field("join", join);
+ }
+ if (cache != null) {
+ builder.field("_cache", cache);
+ }
+ if (cacheKey != null) {
+ builder.field("_cache_key", cacheKey);
+ }
+ if (filterName != null) {
+ builder.field("_name", filterName);
+ }
}
builder.field("path", path);
- if (filterName != null) {
- builder.field("_name", filterName);
- }
- if (cache != null) {
- builder.field("_cache", cache);
- }
- if (cacheKey != null) {
- builder.field("_cache_key", cacheKey);
- }
builder.endObject();
}
}
\ No newline at end of file
diff --git a/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java
index 88ded2a5a7f3..1721b14851d7 100644
--- a/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java
+++ b/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java
@@ -19,6 +19,8 @@
package org.elasticsearch.index.query;
+import org.elasticsearch.Version;
+import org.elasticsearch.common.xcontent.ToXContentUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
@@ -80,7 +82,11 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.field("query");
queryBuilder.toXContent(builder, params);
} else {
- builder.field("filter");
+ if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
+ builder.field("query");
+ } else {
+ builder.field("filter");
+ }
filterBuilder.toXContent(builder, params);
}
builder.field("path", path);
@@ -90,8 +96,10 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
if (boost != 1.0f) {
builder.field("boost", boost);
}
- if (queryName != null) {
- builder.field("_name", queryName);
+ if (!ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
+ if (queryName != null) {
+ builder.field("_name", queryName);
+ }
}
builder.endObject();
}
diff --git a/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java
index cf5db0f0ac16..75275b1aa386 100644
--- a/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java
+++ b/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java
@@ -19,14 +19,14 @@
package org.elasticsearch.index.query;
+import org.elasticsearch.Version;
+import org.elasticsearch.common.xcontent.ToXContentUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
/**
* A filter that simply wraps a query.
- *
- *
*/
public class QueryFilterBuilder extends BaseFilterBuilder {
@@ -66,6 +66,8 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
if (filterName == null && cache == null) {
builder.field(QueryFilterParser.NAME);
queryBuilder.toXContent(builder, params);
+ } else if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
+ queryBuilder.toXContent(builder, params);
} else {
builder.startObject(FQueryFilterParser.NAME);
builder.field("query");