Search requests

edit

While the search API takes a top-level query parameter, the count, delete-by-query and validate-query requests expected the whole body to be a query. These now require a top-level query parameter:

GET /_count
{
    "query": {
        "match": {
            "title": "Interesting stuff"
        }
    }
}

Also, the top-level filter parameter in search has been renamed to post_filter, to indicate that it should not be used as the primary way to filter search results (use a filtered query instead), but only to filter results AFTER facets/aggregations have been calculated.

This example counts the top colors in all matching docs, but only returns docs with color red:

GET /_search
{
    "query": {
        "match_all": {}
    },
    "aggs": {
        "colors": {
            "terms": { "field": "color" }
        }
    },
    "post_filter": {
        "term": {
            "color": "red"
        }
    }
}