Basic Query Question JSON Formatting

I don't know the proper way to format JSON requests to search all indices in ES. When I run:
GET _search?q=dog&size=0
I get 270 hits, but when I run:
GET _search
{
"query": {
"match": {
"about" :"dog"
}
}
}

I get no hits. What is the correct way to make this query return the number of hits?

Thanks

Using ?q=dog is behind the scene generating a query string query not a match query.

So it should be:

GET /_search
{
    "size": 0,
    "query": {
        "query_string" : {
            "query" : "dog"
        }
    }
}

Thank you!

If I would like to get a breakdown on the hit count for each index (the number of documents containing 'dog' in each index), how could I nest an aggregation to do this?

Probably a terms agg on _index field might work.

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