From 14bb703f015c3a356c42a029d4f83ddb9a31443c Mon Sep 17 00:00:00 2001 From: Rahul Anishetty Date: Fri, 27 Jan 2017 03:59:41 +0530 Subject: [PATCH 1/3] support for requesting cache on script in rest client --- pom.xml | 2 +- .../index/query/ScriptFilterBuilder.java | 4 ++++ .../ValuesSourceAggregationBuilder.java | 14 ++++++++++++++ .../ValuesSourceMetricsAggregationBuilder.java | 13 +++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4a96f8c5f6541..3a473d0c0ae6c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 org.elasticsearch elasticsearch - 1.4.1-rest-1.0.36 + 1.4.1-rest-1.0.37 jar Elasticsearch - Open Source, Distributed, RESTful Search Engine 2009 diff --git a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java index bbde937d976ea..d5da739aac35a 100644 --- a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java @@ -118,6 +118,10 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep builder.field("params", this.params); } + if (this.cache != null) { + builder.field("_cache", this.cache); + } + builder.endObject(); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java index 4a54fce2c57f5..b465fe39640a8 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java @@ -37,6 +37,11 @@ public abstract class ValuesSourceAggregationBuilder params; + /** + * request cache for script + */ + private Boolean requestCache; + /** * Constructs a new builder. * @@ -119,6 +124,12 @@ public B params(Map params) { return (B) this; } + @SuppressWarnings("unchecked") + public B requestCache(boolean requestCache) { + this.requestCache = requestCache; + return (B) this; + } + @Override protected final XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); @@ -136,6 +147,9 @@ protected final XContentBuilder internalXContent(XContentBuilder builder, Params if (this.params != null && !this.params.isEmpty()) { builder.field("params").map(this.params); } + if (this.requestCache != null) { + builder.field("_cache", this.requestCache); + } builder.endObject(); } } else { diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java index e73913de394da..a81eebf22be1a 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java @@ -37,6 +37,11 @@ public abstract class ValuesSourceMetricsAggregationBuilder params; + /** + * request cache for script + */ + private Boolean requestCache; + protected ValuesSourceMetricsAggregationBuilder(String name, String type) { super(name, type); } @@ -78,6 +83,11 @@ public B param(String name, Object value) { return (B) this; } + public B requestCache(boolean requestCache){ + this.requestCache = requestCache; + return (B) this; + } + @Override protected void internalXContent(XContentBuilder builder, Params params) throws IOException { if (field != null) { @@ -94,6 +104,9 @@ protected void internalXContent(XContentBuilder builder, Params params) throws I if (this.params != null && !this.params.isEmpty()) { builder.field("params").map(this.params); } + if (this.requestCache != null) { + builder.field("_cache", this.requestCache); + } builder.endObject(); } From c5f955a0d6bfc20f12db1660c64ac0e9a851b9a5 Mon Sep 17 00:00:00 2001 From: Rahul Anishetty Date: Fri, 27 Jan 2017 04:31:19 +0530 Subject: [PATCH 2/3] changed name to cacheable --- .../java/org/elasticsearch/index/query/ScriptFilterBuilder.java | 2 +- .../search/aggregations/ValuesSourceAggregationBuilder.java | 2 +- .../metrics/ValuesSourceMetricsAggregationBuilder.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java index d5da739aac35a..efbfa1df8b136 100644 --- a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java @@ -119,7 +119,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep } if (this.cache != null) { - builder.field("_cache", this.cache); + builder.field("cacheable", this.cache); } builder.endObject(); diff --git a/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java index b465fe39640a8..7430b2f01de0d 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java @@ -148,7 +148,7 @@ protected final XContentBuilder internalXContent(XContentBuilder builder, Params builder.field("params").map(this.params); } if (this.requestCache != null) { - builder.field("_cache", this.requestCache); + builder.field("cacheable", this.requestCache); } builder.endObject(); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java index a81eebf22be1a..85e224a63aee9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java @@ -105,7 +105,7 @@ protected void internalXContent(XContentBuilder builder, Params params) throws I builder.field("params").map(this.params); } if (this.requestCache != null) { - builder.field("_cache", this.requestCache); + builder.field("cacheable", this.requestCache); } builder.endObject(); } From 955bd8286970dac24b1cc2ca86638b3f75d30aab Mon Sep 17 00:00:00 2001 From: Rahul Anishetty Date: Fri, 27 Jan 2017 06:07:37 +0530 Subject: [PATCH 3/3] Revert "changed name to cacheable" This reverts commit c5f955a0d6bfc20f12db1660c64ac0e9a851b9a5. --- .../java/org/elasticsearch/index/query/ScriptFilterBuilder.java | 2 +- .../search/aggregations/ValuesSourceAggregationBuilder.java | 2 +- .../metrics/ValuesSourceMetricsAggregationBuilder.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java index efbfa1df8b136..d5da739aac35a 100644 --- a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java @@ -119,7 +119,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep } if (this.cache != null) { - builder.field("cacheable", this.cache); + builder.field("_cache", this.cache); } builder.endObject(); diff --git a/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java index 7430b2f01de0d..b465fe39640a8 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java @@ -148,7 +148,7 @@ protected final XContentBuilder internalXContent(XContentBuilder builder, Params builder.field("params").map(this.params); } if (this.requestCache != null) { - builder.field("cacheable", this.requestCache); + builder.field("_cache", this.requestCache); } builder.endObject(); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java index 85e224a63aee9..a81eebf22be1a 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java @@ -105,7 +105,7 @@ protected void internalXContent(XContentBuilder builder, Params params) throws I builder.field("params").map(this.params); } if (this.requestCache != null) { - builder.field("cacheable", this.requestCache); + builder.field("_cache", this.requestCache); } builder.endObject(); }