Searching Multiple types within an Index not providing results as expected


(Ramdev Wudali) #1

Hi :
I have two types ("type1", and "type2") within my index "index1". When I
perform a search

I index two documents with the same id (the mappings are different but the
two types are "linked" via an "id" field) in each of the types. The "id"
field has the same value in the two types.

curl -XPOST "http://localhost:9200/index1/type1,type2/_search" -d'
{
"query" :
{
"term": {
"id": {
"value": "10100"
}
}
}
}'

I expect two hits (1 from "type1" and another from "type2"). However, I
only get the document from "type1" (which was incidentally indexed first).
However, If I perform these two queries separately :

curl -XPOST "http://localhost:9200/index1/type1/_search" -d'
{
"query" :
{
"term": {
"id": {
"value": "10100"
}
}
}
}'

AND

curl -XPOST "http://localhost:9200/index1/type2/_search" -d'
{
"query" :
{
"term": {
"id": {
"value": "10100"
}
}
}
}'

I retrieve two hits (one from each type).

What might be happening that is causing only one document to be returned
when I search across the two types.

Thanks

Ramdev

--
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/2ea05272-8a79-4319-b546-fa73b0183e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Brian Yoder) #2

When you query each type separately, ES is automatically choosing the
correct analyzer for your query term.

But when you query both types, ES can only choose one analyzer, and if the
two types are mapped with analyzers that are different enough, that one
analyzer will work in the type to which it belongs but not to the other
type.

A good way to let us check this would be to create a gist with the full set
of settings and mappings for your index.

Brian

--
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/f07b5ad2-e851-458d-adcb-ddb9abefd26c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3