Skip to content

Commit 38174b5

Browse files
Merge pull request #13 from rahul1193/rahul/rest-client-1.4.1
support for requesting cache on script in rest client
2 parents 80db68a + 955bd82 commit 38174b5

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>org.elasticsearch</groupId>
88
<artifactId>elasticsearch</artifactId>
9-
<version>1.4.1-rest-1.0.36</version>
9+
<version>1.4.1-rest-1.0.37</version>
1010
<packaging>jar</packaging>
1111
<description>Elasticsearch - Open Source, Distributed, RESTful Search Engine</description>
1212
<inceptionYear>2009</inceptionYear>

src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
118118
builder.field("params", this.params);
119119
}
120120

121+
if (this.cache != null) {
122+
builder.field("_cache", this.cache);
123+
}
124+
121125
builder.endObject();
122126

123127
builder.endObject();

src/main/java/org/elasticsearch/search/aggregations/ValuesSourceAggregationBuilder.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public abstract class ValuesSourceAggregationBuilder<B extends ValuesSourceAggre
3737
private String lang;
3838
private Map<String, Object> params;
3939

40+
/**
41+
* request cache for script
42+
*/
43+
private Boolean requestCache;
44+
4045
/**
4146
* Constructs a new builder.
4247
*
@@ -119,6 +124,12 @@ public B params(Map<String, Object> params) {
119124
return (B) this;
120125
}
121126

127+
@SuppressWarnings("unchecked")
128+
public B requestCache(boolean requestCache) {
129+
this.requestCache = requestCache;
130+
return (B) this;
131+
}
132+
122133
@Override
123134
protected final XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException {
124135
builder.startObject();
@@ -136,6 +147,9 @@ protected final XContentBuilder internalXContent(XContentBuilder builder, Params
136147
if (this.params != null && !this.params.isEmpty()) {
137148
builder.field("params").map(this.params);
138149
}
150+
if (this.requestCache != null) {
151+
builder.field("_cache", this.requestCache);
152+
}
139153
builder.endObject();
140154
}
141155
} else {

src/main/java/org/elasticsearch/search/aggregations/metrics/ValuesSourceMetricsAggregationBuilder.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public abstract class ValuesSourceMetricsAggregationBuilder<B extends ValuesSour
3737
private String lang;
3838
private Map<String, Object> params;
3939

40+
/**
41+
* request cache for script
42+
*/
43+
private Boolean requestCache;
44+
4045
protected ValuesSourceMetricsAggregationBuilder(String name, String type) {
4146
super(name, type);
4247
}
@@ -78,6 +83,11 @@ public B param(String name, Object value) {
7883
return (B) this;
7984
}
8085

86+
public B requestCache(boolean requestCache){
87+
this.requestCache = requestCache;
88+
return (B) this;
89+
}
90+
8191
@Override
8292
protected void internalXContent(XContentBuilder builder, Params params) throws IOException {
8393
if (field != null) {
@@ -94,6 +104,9 @@ protected void internalXContent(XContentBuilder builder, Params params) throws I
94104
if (this.params != null && !this.params.isEmpty()) {
95105
builder.field("params").map(this.params);
96106
}
107+
if (this.requestCache != null) {
108+
builder.field("_cache", this.requestCache);
109+
}
97110
builder.endObject();
98111
}
99112

0 commit comments

Comments
 (0)