Search code examples
elasticsearchnestelastic-appsearch

How to prevent ignored fields from being returned from Elastic Search


We have an Elastic Search engine that has been provisioned through App Search, and has a very large schema (large amount of fields). A lot of these fields are not necessary to the scope of our search requests and are returned in the _ignored section of the response object. Not only do we not use the _ignored data, but they are significantly bloating our response object from Elastic which is not ideal. Is there a way to prevent the _ignored section form being returned as a part of the result from a search request?

Edit An example of the request and response enter image description here


Solution

  • _ignored is metadata field of elasticsearch hence it can not be filter using source filter option.

    You need to use Response Filtering using filter_path parameter in request.

    Below is example where it will return only took, _id, _score, _source in search response.

    POST index_name/_search?filter_path=took,hits.hits._id,hits.hits._score,hits.hits._source
    {
      "query": {
        "exists": {
          "field": "_ignored"
        }
      }
    }