I have two indices my_index_1 and my_index_2. Within these indices, I have the following document types:
my_index_1:
my_index_2:
Each of the types has different fields.
My Question: What is the best way to query for the string "abc" in any field of any type, across any one or even both indices?
I don't see anything in the documentation that facilitates such a search. Is there something that might look like:
$ curl -XPOST 'localhost:9200/_search?pretty' -d '
{
"query": { "match": { *: "abc" } }
}'
Thanks, in advance, for any help you can offer.
Either the query_string query or the match query would be what you're looking for.
query_string will use the special _all field if none is specified in default_field, so that would work out well.
curl -XPOST 'localhost:9200/_search?pretty' -d '{
"query": { "query_string": { "query": "abc" } }
}'
And with match you can just specify the _all as well.
curl -XPOST 'localhost:9200/_search?pretty' -d '{
"query": { "match": { "_all": "abc" } }
}'
Note that with query_string you may use wildcards, which you can't with match
UPDATE:
As the _all field was deprecated in 6.0, the solution is now to implement a custom all field
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With