You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Creating mapping with two nested properties, customData and experiments
curl -XPUT 'http://localhost:9200/test_index/_mapping/test_mapping' -d '{"test_mapping":{"properties":{"customData":{"type":"nested","properties":{"id":{"type":"integer","doc_values":true},"value":{"type":"string","index":"not_analyzed","doc_values":true}}},"experiments":{"type":"nested","properties":{"id":{"type":"long","doc_values":true},"variationId":{"type":"long","doc_values":true}}}}}}'
// Querying for same document using second subproperty of experiments, everything OK
curl -XGET 'http://localhost:9200/test_index/_search?size=1&pretty=true' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"_id":"test_document"}},{"nested":{"path":"experiments","filter":{"term":{"variationId":83517}}}}]}}}}'
// Querying for same document using second subproperty of experiments, everything OK
curl -XGET 'http://localhost:9200/test_index/_search?size=1&pretty=true' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"_id":"test_document"}},{"nested":{"path":"experiments","filter":{"term":{"variationId":83517}}}}]}}}}'
=> ... "hits" : { "total" : 1 ...}
// Querying for same document using first subproperty of experiments, everything OK
curl -XGET 'http://localhost:9200/test_index/_search?size=1&pretty=true' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"_id":"test_document"}},{"nested":{"path":"experiments","filter":{"term":{"id":13048}}}}]}}}}'
=> ... "hits" : { "total" : 1 ...}
I am becoming crazy, has anyone else seen the same problems?
The text was updated successfully, but these errors were encountered:
You're not going crazy :) The problem is that you have two nested fields called id, and you're not using the whole path name. If you change your filter from:
"term": {
"id": 13048
}
to
"term": {
"experiments.id": 13048
}
then everything works correctly.
Issue #8872 will enforce the requirement to use the full path name on all fields
(Tested on ES 1.3.4 and 1.4.2)
When I do the following commands:
// Creating index
curl -XPUT 'http://localhost:9200/test_index'
// Creating mapping with two nested properties, customData and experiments
curl -XPUT 'http://localhost:9200/test_index/_mapping/test_mapping' -d '{"test_mapping":{"properties":{"customData":{"type":"nested","properties":{"id":{"type":"integer","doc_values":true},"value":{"type":"string","index":"not_analyzed","doc_values":true}}},"experiments":{"type":"nested","properties":{"id":{"type":"long","doc_values":true},"variationId":{"type":"long","doc_values":true}}}}}}'
// Creating document in mapping
curl -XPUT 'http://localhost:9200/test_index/test_mapping/test_document' -d '{"experiments":[{"id":13048,"variationId":83517}],"customData":[]}'
// Querying for same document using second subproperty of experiments, everything OK
curl -XGET 'http://localhost:9200/test_index/_search?size=1&pretty=true' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"_id":"test_document"}},{"nested":{"path":"experiments","filter":{"term":{"variationId":83517}}}}]}}}}'
=> ... "hits" : { "total" : 1 ...}
// Querying for same document using first subproperty of experiments, DOES NOT FIND DOCUMENT
curl -XGET 'http://localhost:9200/test_index/_search?size=1&pretty=true' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"_id":"test_document"}},{"nested":{"path":"experiments","filter":{"term":{"id":13048}}}}]}}}}'
curl -XDELETE 'http://http://localhost:9200/test_index/'
=> ... "hits" : { "total" : 0 ...}
If I do the same commands but with a mapping containing only the second nested property, everything works as expected:
curl -XPUT 'http://localhost:9200/test_index'
curl -XPUT 'http://localhost:9200/test_index/_mapping/test_mapping' -d '{"test_mapping":{"properties":{"experiments":{"type":"nested","properties":{"id":{"type":"long","doc_values":true},"variationId":{"type":"long","doc_values":true}}}}}}'
curl -XPUT 'http://http://localhost:9200/test_index/test_mapping/test_document' -d '{"experiments":[{"id":13048,"variationId":83517}]}'
// Querying for same document using second subproperty of experiments, everything OK
curl -XGET 'http://localhost:9200/test_index/_search?size=1&pretty=true' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"_id":"test_document"}},{"nested":{"path":"experiments","filter":{"term":{"variationId":83517}}}}]}}}}'
=> ... "hits" : { "total" : 1 ...}
// Querying for same document using first subproperty of experiments, everything OK
curl -XGET 'http://localhost:9200/test_index/_search?size=1&pretty=true' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"_id":"test_document"}},{"nested":{"path":"experiments","filter":{"term":{"id":13048}}}}]}}}}'
=> ... "hits" : { "total" : 1 ...}
I am becoming crazy, has anyone else seen the same problems?
The text was updated successfully, but these errors were encountered: