Searching across multiple types returns doesn't find all documents matching

I include a bash script that recreates the situation.

#!/bin/sh

curl -XDELETE "http://localhost:9200/test"
curl -XPUT "http://localhost:9200/test"

echo

curl -XPUT "http://localhost:9200/test/foo/_mapping" -d '{
"foo" : {
"properties" : {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"foo_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
}
}
}
}'

echo

#foo is a basically a duplicate of the foo document to support search use cases
curl -XPUT "http://localhost:9200/test/bar/_mapping" -d '{
"bar" : {
"properties" : {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"bar_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
},
"foo": {
"properties": {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"foo_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
}
}
}
}
}
}'

echo

curl -XPUT "http://localhost:9200/test/foo/1?refresh=true" -d '{
"foo": {
"id": 1
}
}'

echo

#failure case appears even when not including the following JSON

"bar": {

"id": 2,

"foo": {

"id": 3

}

}

curl -XPUT "http://localhost:9200/test/bar/2?refresh=true" -d '{
"bar": {
"id": 2
}
}'

echo

#expect two results, get one (FAIL)
curl -XPOST "http://localhost:9200/test/foo,bar/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#except one result, get one (PASS)
curl -XPOST "http://localhost:9200/test/bar/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#expect one result, get one result (PASS)
curl -XPOST "http://localhost:9200/test/foo/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#expect two results, get tow results (PASS)
curl -XPOST "http://localhost:9200/test/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

--
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/1d8f1ea8-db1b-425c-b6ee-153f5f369f43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello Ben ,

This is the type/field ambiguity bug -

Basically , if you use the field name and type name as same , this might
come up.
Make these two different and it should work.

Thanks
Vineeth

On Thu, Sep 11, 2014 at 4:17 AM, ben billumina2@gmail.com wrote:

I include a bash script that recreates the situation.

#!/bin/sh

curl -XDELETE "http://localhost:9200/test"
curl -XPUT "http://localhost:9200/test"

echo

curl -XPUT "http://localhost:9200/test/foo/_mapping" -d '{
"foo" : {
"properties" : {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"foo_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
}
}
}
}'

echo

#foo is a basically a duplicate of the foo document to support search use cases
curl -XPUT "http://localhost:9200/test/bar/_mapping" -d '{
"bar" : {
"properties" : {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"bar_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
},
"foo": {
"properties": {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"foo_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
}
}
}
}
}
}'

echo

curl -XPUT "http://localhost:9200/test/foo/1?refresh=true" -d '{
"foo": {
"id": 1
}
}'

echo

#failure case appears even when not including the following JSON

"bar": {

"id": 2,

"foo": {

"id": 3

}

}

curl -XPUT "http://localhost:9200/test/bar/2?refresh=true" -d '{
"bar": {
"id": 2
}
}'

echo

#expect two results, get one (FAIL)
curl -XPOST "http://localhost:9200/test/foo,bar/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#except one result, get one (PASS)
curl -XPOST "http://localhost:9200/test/bar/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#expect one result, get one result (PASS)
curl -XPOST "http://localhost:9200/test/foo/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#expect two results, get tow results (PASS)
curl -XPOST "http://localhost:9200/test/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

--
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/1d8f1ea8-db1b-425c-b6ee-153f5f369f43%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/1d8f1ea8-db1b-425c-b6ee-153f5f369f43%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CAGdPd5%3DJAwmeymjLcb-%3DApxCp%3DFfhSKMUnmxw-97UqLtaL3W4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Thank you!

On Wednesday, September 10, 2014 8:59:31 PM UTC-7, vineeth mohan wrote:

Hello Ben ,

This is the type/field ambiguity bug -
Field resolution should be unambiguous · Issue #4081 · elastic/elasticsearch · GitHub

Basically , if you use the field name and type name as same , this might
come up.
Make these two different and it should work.

Thanks
Vineeth

On Thu, Sep 11, 2014 at 4:17 AM, ben <billu...@gmail.com <javascript:>>
wrote:

I include a bash script that recreates the situation.

#!/bin/sh

curl -XDELETE "http://localhost:9200/test"
curl -XPUT "http://localhost:9200/test"

echo

curl -XPUT "http://localhost:9200/test/foo/_mapping" -d '{
"foo" : {
"properties" : {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"foo_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
}
}
}
}'

echo

#foo is a basically a duplicate of the foo document to support search use cases
curl -XPUT "http://localhost:9200/test/bar/_mapping" -d '{
"bar" : {
"properties" : {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"bar_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
},
"foo": {
"properties": {
"id": {
"type" : "multi_field",
"path": "full",
"fields" : {
"foo_id_in_another_field" : {"type" : "long", include_in_all:false },
"id" : {"type" : "long"}
}
}
}
}
}
}
}'

echo

curl -XPUT "http://localhost:9200/test/foo/1?refresh=true" -d '{
"foo": {
"id": 1
}
}'

echo

#failure case appears even when not including the following JSON

"bar": {

"id": 2,

"foo": {

"id": 3

}

}

curl -XPUT "http://localhost:9200/test/bar/2?refresh=true" -d '{
"bar": {
"id": 2
}
}'

echo

#expect two results, get one (FAIL)
curl -XPOST "http://localhost:9200/test/foo,bar/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#except one result, get one (PASS)
curl -XPOST "http://localhost:9200/test/bar/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#expect one result, get one result (PASS)
curl -XPOST "http://localhost:9200/test/foo/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

echo

#expect two results, get tow results (PASS)
curl -XPOST "http://localhost:9200/test/_search?pretty=true" -d '{
"size": 10,
"query": {
"query_string": {
"query": "foo.id:1 OR bar.id:2"
}
}
}'

--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/1d8f1ea8-db1b-425c-b6ee-153f5f369f43%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/1d8f1ea8-db1b-425c-b6ee-153f5f369f43%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/0a550ac5-4ed9-4a6e-89b5-100b2be813a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.