Query problem with nested fields using DSL with elasticsearch

When I try to query a nested field that exists, I didn't get any result (it
isn't return any error):

            result = es.search(
                      index="mydb", 
                      doc_type="collection", 
                      body={"query": 
                        { 
                              "term" : {
                                  "foo.bar.field" : value
                              }
                        }
                      }
                    )

NOTE: field is inside bar and bar is inside foo:

{ 'topfield' : 23, 'foo' : { 'bar' : { 'field' : 69 }, 'otherfield' : 1}}

If I try the same with a field in the top, it works properly:

            result = es.search(
                      index="mydb", 
                      doc_type="collection", 
                      body={"query": 
                        { 
                              "term" : {
                                  "topfield" : value
                              }
                        }
                      }
                    )

--
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/93d419b4-f409-4c57-a2e0-fe528efd3569%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You should use path for your nested fields!!!
please read this article:

Am Mittwoch, 15. Oktober 2014 10:38:24 UTC+2 schrieb José Ramón Palanco:

When I try to query a nested field that exists, I didn't get any result
(it isn't return any error):

            result = es.search(
                      index="mydb", 
                      doc_type="collection", 
                      body={"query": 
                        { 
                              "term" : {
                                  "foo.bar.field" : value
                              }
                        }
                      }
                    )

NOTE: field is inside bar and bar is inside foo:

{ 'topfield' : 23, 'foo' : { 'bar' : { 'field' : 69 }, 'otherfield' : 1}}

If I try the same with a field in the top, it works properly:

            result = es.search(
                      index="mydb", 
                      doc_type="collection", 
                      body={"query": 
                        { 
                              "term" : {
                                  "topfield" : value
                              }
                        }
                      }
                    )

--
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/6e045b5f-b709-49a1-9422-5c5bb8ffb8ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.