Skip to content

Commit

Permalink
Merge pull request #11 from rahul1193/rahul/rest-client-1.4.1
Browse files Browse the repository at this point in the history
NPE fix for in or, and and not filters
  • Loading branch information
brandonkearby authored Jan 20, 2017
2 parents b671e8c + ca60594 commit 6b4da25
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.4.1-rest-1.0.34</version>
<version>1.4.1-rest-1.0.35</version>
<packaging>jar</packaging>
<description>Elasticsearch - Open Source, Distributed, RESTful Search Engine</description>
<inceptionYear>2009</inceptionYear>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ public AndFilterBuilder filterName(String filterName) {
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
FilterBuilders.boolFilter()
BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter()
.filterName(filterName)
.must(filters.toArray(new FilterBuilder[filters.size()]))
.cache(cache)
.cacheKey(cacheKey)
.doXContent(builder, params);
.cacheKey(cacheKey);
if (this.cache != null) {
boolFilterBuilder.cache(this.cache);
}
boolFilterBuilder.doXContent(builder, params);
} else {
builder.startObject(AndFilterParser.NAME);
builder.startArray("filters");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ public NotFilterBuilder filterName(String filterName) {
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
FilterBuilders.boolFilter()
BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter()
.mustNot(filter)
.filterName(filterName)
.cache(cache)
.doXContent(builder, params);
.filterName(filterName);
if (this.cache != null) {
boolFilterBuilder.cache(this.cache);
}
boolFilterBuilder.doXContent(builder, params);
} else {
builder.startObject(NotFilterParser.NAME);
builder.field("filter");
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/org/elasticsearch/index/query/OrFilterBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ public OrFilterBuilder filterName(String filterName) {
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
if (ToXContentUtils.getVersionFromParams(params).onOrAfter(Version.V_5_0_0)) {
FilterBuilders.boolFilter()
BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter()
.filterName(filterName)
.should(filters.toArray(new FilterBuilder[filters.size()]))
.cacheKey(cacheKey)
.cache(cache)
.doXContent(builder, params);
.cacheKey(cacheKey);
if (this.cache != null) {
boolFilterBuilder.cache(this.cache);
}
boolFilterBuilder.doXContent(builder, params);

} else {
builder.startObject(OrFilterParser.NAME);
builder.startArray("filters");
Expand Down

0 comments on commit 6b4da25

Please sign in to comment.