title: Elasticsearch query innerobject
body: <p>I want to filter on an inner object but I'm not able to get my data. I have the following elasticsearch mapping:</p>
  
  <pre><code>{
    "settings" : {
      "number_of_shards" : 1,
      "analysis" : {
        "filter" : {
          "technologies_synonym" : {
            "type" : "synonym",
            "synonyms_path" : "elasticsearch/synonyms/technologies.txt"
          }
        },
        "analyzer" : {
          "technologies_synonyms" : {
            "tokenizer" : "whitespace",
            "filter" : ["standard", "lowercase", "stop", "technologies_synonym"],
            "type" : "custom"
          }
        }
      }
    },
    "mappings": {
      "company" : {
        "properties" : {
          "name" : { "type" : "string", "store" : "yes" },
          "logo" : { "type" : "string", "store" : "yes" },
          "website" : { "type" : "string", "store" : "yes" },
          "employees" : { "type" : "string", "store" : "yes" },
          "technologies" : { "type" : "string", "store" : "yes", "analyzer" : "technologies_synonyms" },
          "locations" : {
            "properties": {
              "city" : { "type" : "string", "store" : "yes" },
              "country" : { "type" : "string", "store" : "yes" },
              "coordinates" : { "type" : "geo_point", "store" : "yes" },
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>My mapping use an inner object for locations, because a company can be located in several places. I also tried to replace the inner object by a nested.</p>
  
  <pre><code>{
    "mapping" : {
      "properties" : {
        # ...
        "locations" : { "type" : "nested" }
      }
  }
  </code></pre>
  
  <p>When I query my companies objects on the other fields, I'm able to get the expecting results, but when I filter on a country I have no results.</p>
  
  <p>Tried queries:</p>
  
  <pre><code>curl 'http://localhost:9200/myapp/company/_search?pretty=true' -XPOST -d '{
     "query": {
       "filtered": {
         "query": { "match_all": {} },
         "filter": {
           "nested": {
             "path": "locations",
             "filter": {
               "bool": {
                 "must": [
                   {
                     "term": { "locations.country": "France" }
                   }
                 ]
               }
             }
           }
         }
       }
     }
   }
  
   curl 'http://localhost:9200/tekusage/company/_search?pretty=true' -XPOST -d '{
       "query": {
         "filtered": {
           "filter": {
             "bool": {
               "must": [
                 {
                   "term": {
                     "technologies": "ruby"
                   }
                 },
                 {
                   "term": {
                     "company.locations.country": "France"
                   }
                 },
                 {
                   "term": {
                     "company.locations.city": "Lille"
                   }
                 }
               ]
             }
           }
         }
       }
     }'
  </code></pre>
  
  <p>Do you have some idea to help me to get my data ?</p>
  
  <p>Thanks,
  Kevin</p>