title: How to remove extra fields from ElasticSearch response
body: <blockquote>
    <p>Hi I am very new to the ElasticSearch and I am struggling to remove all extra fields from response getting from ElasticSearch. Please see below response:</p>
  </blockquote>
  
  <pre><code>  "report": {
      "unique_users": {
        "doc_count_error_upper_bound": 0,
        "sum_other_doc_count": 0,
        "buckets": [
          {
            "key": 1234,
            "doc_count": 2,
            "user_details": {
              "hits": {
                "total": 2,
                "max_score": 1.4E-45,
                "hits": [
                  {
                    "_index": "orders-test",
                    "_type": "order",
                    "_id": "2",
                    "_score": 0.0,
                    "_source": {
                      "customer_email": "reba_dickens@blick.name",
                      "customer_phone": "476.824.4998 x498",
                      "customer_name": "Mohammed Abernathy"
                    }
                  }
                ]
              }
            }
          },
          {
            "key": 5678,
            "doc_count": 1,
            "user_details": {
              "hits": {
                "total": 1,
                "max_score": 1.4E-45,
                "hits": [
                  {
                    "_index": "orders-test",
                    "_type": "order",
                    "_id": "1",
                    "_score": 0.0,
                    "_source": {
                      "customer_email": "yolanda.batz@ruel.biz",
                      "customer_phone": "1-715-183-8343 x026",
                      "customer_name": "Richie Tillman II"
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  </code></pre>
  
  <blockquote>
    <p>Above you can see that there are some additional fields coming with the response like _index, _type, _score, max_score etc. I have followed ElasticSearch <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering" rel="nofollow noreferrer">response_filtering</a> guide to remove these fields but it was not working for me. I have also passed the filter_path parameter to the request <a href="http://0.0.0.0:5000/v4/reports/user.json?filter_path=unique_users,unique_users.user_details.hits.hits._source" rel="nofollow noreferrer">0.0.0.0:5000/v4/reports/user.json?filter_path=unique_users,unique_users.user_details.hits.hits._source</a> but did not get any response. I am using below function to process the Elasticsearch query.</p>
  </blockquote>
  
  <pre><code>  def query(options = {})
  
      aggregations = {}
  
      buckets = {}
      buckets_for_unique_users buckets, aggregations
      buckets_for_new_users buckets, aggregations
      buckets_for_high_rollers buckets, aggregations
  
      filters = []
      filters &lt;&lt; time_filter(options)
      filters &lt;&lt; restaurant_filter(options) if options[:restaurant_id]
      filters &lt;&lt; channel_filter(options) if options[:channel_id]
  
      query = {
        query: { bool: { filter: filters } },
        aggregations: buckets
      }
      query
    end
  </code></pre>
  
  <blockquote>
    <p>Could anyone please let me know where I am doing wrong.</p>
  </blockquote>