Search query to return data from multiple types of same index

I have data in three different types of same index.
Say type data1 has
{ "city" : "BELCHERTOWN",
"city" : "BLANDFORD",
"city" : "BRIMFIELD" }
data2 has
{
"city" : "BELCHERTOWN",
"city" : "BLANDFORD",
"city" : "BRIMFIELD"
}
data3 has
{
"city7" : "CHESTER",
"city8" : "CHESTERFIELD",
"city9" : "CHICOPEE"
}

So if i search for BRIMFIELD
{
"query": {
"query_string": {
"query": "BRIMFIELD"
}
}
}
it returns all the three cities from data 2 but is it possible to return cities from all other two types as well?

First a side note, please avoid using multiple types as this will be deprecated in version 6
Which endpoint are you using?

GET /indicename/_search endpoint will run query on all types of the index.

And if you have 3 indices so each index has one type, you can define an alias (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html) for those 3 indices or you could use wildcard instead GET /partofindexname*/_search

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