# "Failed to derive xcontent" - elasticsearch-ruby/dsl

**URL:** <https://discuss.elastic.co/t/failed-to-derive-xcontent-elasticsearch-ruby-dsl/68770>\
**Category:** Elasticsearch\
**Created:** [December 12, 2016, 8:59pm UTC](https://discuss.elastic.co/t/failed-to-derive-xcontent-elasticsearch-ruby-dsl/68770 "2016-12-12T20:59:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay-snee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jay-snee/32/13816_2.png) [@jay-snee](https://discuss.elastic.co/u/jay-snee)\
**Post date:** [December 12, 2016, 8:59pm UTC](https://discuss.elastic.co/t/failed-to-derive-xcontent-elasticsearch-ruby-dsl/68770/1 "2016-12-12T20:59:33Z")

</div>

Hello!

I'm getting the following error when attempting to a run a query from a Rails app -

```
2016-12-12T17:33:08.461564758Z app[web.4]: --> GET my-lovely-index/_search {} {"aggregations":{"items":{"nested":{"path":"items"},"aggregations":{"name":{"terms":{"field":"items.name","size":1000000}}}}}}
2016-12-12T17:33:09.959661891Z app[web.4]: --> RESPONSE {"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to derive xcontent"}],"type":"parse_exception","reason":"Failed to derive xcontent"},"status":400}

```

I can copy the query from the logs and run it via the Dev Console/Sense and it runs fine.

I've tried:

- Removing the `size` param
- `bundle update` =\> redeploy
- App server update/bounce
- Cluster reprovisioning/memory increase

The ES Ruby DSL code looks like:

```
query_definition = search do
  aggregation :items do
    nested do
      path nested_fields
      aggregation :name do
        terms do
          field field_name
        end
      end
    end
  end
end

terms_response = client.search index: index, body: query_definition.to_json

```

Cluster in question is: a49768

Any clues as to where I've gone wrong are appreciated, thanks! 🙂

---

<div class="post-metadata">

**Author:** ![cstrzadala](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cstrzadala/32/8211_2.png) [@cstrzadala](https://discuss.elastic.co/u/cstrzadala)\
**Post date:** [December 14, 2016, 12:49am UTC](https://discuss.elastic.co/t/failed-to-derive-xcontent-elasticsearch-ruby-dsl/68770/2 "2016-12-14T00:49:24Z")

</div>

Hi @jay-snee,

As this seems to be a Elasticsearch Ruby DSL issue, I can't help you directly with this from the cloud channel. I'll move this to the Elasticsearch channel where users of the Ruby DSL may be able to help you there.

Christian

---

<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:** [December 17, 2016, 12:49am UTC](https://discuss.elastic.co/t/failed-to-derive-xcontent-elasticsearch-ruby-dsl/68770/3 "2016-12-17T00:49:40Z")

</div>

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