# ES 5.1.X - REST API with SearchSourceBuilder bug?

**URL:** <https://discuss.elastic.co/t/es-5-1-x-rest-api-with-searchsourcebuilder-bug/71560>\
**Category:** Elasticsearch\
**Created:** [January 13, 2017, 6:41pm UTC](https://discuss.elastic.co/t/es-5-1-x-rest-api-with-searchsourcebuilder-bug/71560 "2017-01-13T18:41:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erik\_dreyer](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@erik\_dreyer](https://discuss.elastic.co/u/erik_dreyer)\
**Post date:** [January 13, 2017, 6:41pm UTC](https://discuss.elastic.co/t/es-5-1-x-rest-api-with-searchsourcebuilder-bug/71560/1 "2017-01-13T18:41:58Z")

</div>

I'm using the following in my Java project.

```
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/rest -->
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>rest</artifactId>
    <version>5.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>5.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/transport -->
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>5.1.1</version>
</dependency>

```

I'm using `SearchSourceBuilder` to build a query, which I then execute against the new REST API.

Specifically, I'm running a count query `.../_count`. The problem is that SearchSourceBuilder generates this as part of the query: `{ ..., ext:{} }` which is not allows for `/_count` queries.

There seems to be no way to disable the generation of this field (null not allowed):

```
public SearchSourceBuilder ext(List<SearchExtBuilder> searchExtBuilders) {
    this.extBuilders = Objects.requireNonNull(searchExtBuilders, "searchExtBuilders must not be null");
    return this;
}

```

Is this a bug? Am I missing something? Or is there another preferred way to generate the queries?

Thanks,  
Erik

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 10, 2017, 6:42pm UTC](https://discuss.elastic.co/t/es-5-1-x-rest-api-with-searchsourcebuilder-bug/71560/2 "2017-02-10T18:42:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
