Hi Mohit
All documents stored in a single index are stored at the same "level",
regardless of their type. The "_type" is just a hidden field in each
document. So if you do a search like:
GET /index_one,index_two/_search
{ "query": { "match": { "field_foo": "some search terms" }}}
then it queries each shard in index_one and index_two and reduces the
results. For each index, it looks for "field_foo" in all of the types
defined in that index and uses the mapping for the first "field_foo" that
it finds. (This is why fields with the same name but in different types
should be mapped in the same way).
If you do a search like this:
GET /index_on,index_two/type_one,type_two/_search
{ "query": { "match": { "field_foo": "some search terms" }}}
then everything works in the same way except:
- it looks only in type_one and type_two for "field_foo" (and uses the
first one that it finds)
- it adds a filter like { "terms": { "_type": [ "type_one", "type_two" ]}}
If you do a search like this:
GET /index_on,index_two/type_one,type_two/_search
{ "query": {
"multi_match": {
"fields: [ "type_one.field_foo", "type_two.field_foo" ]
"query": "some search terms"
}
}
the the mapping for type_one.field_foo and type_two.field_foo are
considered independently, and the query is rewritten to look something like
this:
{
"query": {
"dis_max": {
"queries": [
{
"filtered": {
"query": { "match": {"field_foo": "some search terms" }},
"filter": { "term": { "_type": "type_one" }}
}
},
{
"filtered": {
"query": { "match": {"field_foo": "some search terms" }},
"filter": { "term": { "_type": "type_one" }}
}
}
]
}
}
}
clint
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPt3XKS37RArKVPM%3DnZjEs4roDHV89W2GUUxNjnqaAxD9ri2jw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.