Search query to return data from multiple types of same index


#1

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?


(Julien) #2

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


(system) #3

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