OpenSearch/rest-api-spec/test/search
Tanguy Leroux ce63590bd6 API: Add response filtering with filter_path parameter
This change adds a new "filter_path" parameter that can be used to filter and reduce the responses returned by the REST API of elasticsearch.

For example, returning only the shards that failed to be optimized:
```
curl -XPOST 'localhost:9200/beer/_optimize?filter_path=_shards.failed'
{"_shards":{"failed":0}}%
```

It supports multiple filters (separated by a comma):
```
curl -XGET 'localhost:9200/_mapping?pretty&filter_path=*.mappings.*.properties.name,*.mappings.*.properties.title'
```

It also supports the YAML response format. Here it returns only the `_id` field of a newly indexed document:
```
curl -XPOST 'localhost:9200/library/book?filter_path=_id' -d '---hello:\n  world: 1\n'
---
_id: "AU0j64-b-stVfkvus5-A"
```

It also supports wildcards. Here it returns only the host name of every nodes in the cluster:
```
curl -XGET 'http://localhost:9200/_nodes/stats?filter_path=nodes.*.host*'
{"nodes":{"lvJHed8uQQu4brS-SXKsNA":{"host":"portable"}}}
```

And "**" can be used to include sub fields without knowing the exact path. Here it returns only the Lucene version of every segment:
```
curl 'http://localhost:9200/_segments?pretty&filter_path=indices.**.version'
{
  "indices" : {
    "beer" : {
      "shards" : {
        "0" : [ {
          "segments" : {
            "_0" : {
              "version" : "5.2.0"
            },
            "_1" : {
              "version" : "5.2.0"
            }
          }
        } ]
      }
    }
  }
}
```

Note that elasticsearch sometimes returns directly the raw value of a field, like the _source field. If you want to filter _source fields, you should consider combining the already existing _source parameter (see Get API for more details) with the filter_path parameter like this:

```
curl -XGET 'localhost:9200/_search?pretty&filter_path=hits.hits._source&_source=title'
{
  "hits" : {
    "hits" : [ {
      "_source":{"title":"Book #2"}
    }, {
      "_source":{"title":"Book #1"}
    }, {
      "_source":{"title":"Book #3"}
    } ]
  }
}
```
2015-05-26 13:51:04 +02:00
..
10_source_filtering.yaml [TEST] remove old tests from yaml test suite 2014-01-07 16:19:06 +01:00
20_default_values.yaml [TEST] Replaced RestTestSuiteRunner with parametrized test that uses RandomizedRunner directly 2014-04-07 17:08:05 +02:00
30_template_query_execution.yaml Add simple escape method for special characters to template query 2014-03-20 18:48:14 +01:00
40_search_request_template.yaml [API] renaming search-template to search_template. 2014-03-20 21:58:08 +01:00
50_search_count.yaml Search: Remove the `count` search type. 2015-03-31 11:31:49 +02:00
60_query_string.yaml REST: Unify query_string parameters parsing 2015-05-11 11:32:59 +02:00
70_response_filtering.yaml API: Add response filtering with filter_path parameter 2015-05-26 13:51:04 +02:00
issue4895.yaml Throw exception if an additional field was placed inside the "query" body 2014-04-25 08:57:06 +02:00
issue9606.yaml Remove (dfs_)query_and_fetch from the REST API 2015-04-28 15:27:59 -07:00
test_sig_terms.yaml significant terms: fix json response 2014-06-18 18:51:34 +02:00