title: Querystring search on array elements in Elastic Search
body: <p>I'm trying to learn elasticsearch with a simple example application, that lists quotations associated with people. The example mapping might look like:</p>
  
  <pre><code>{ 
    "people" : {
      "properties" : {
        "name" : { "type" : "string"},
        "quotations" : { "type" : "string" }
      }
    }
  }
  </code></pre>
  
  <p>Some example data might look like: </p>
  
  <pre><code>{ "name" : "Mr A",
    "quotations" : [ "quotation one, this and that and these"
                   , "quotation two, those and that"]
  }
  
  { "name" : "Mr B",
    "quotations" : [ "quotation three, this and that"
                   , "quotation four, those and these"]
  }
  </code></pre>
  
  <p>I would like to be able to use the querystring api on individual quotations, and return the people who match. For instance, I might want to find people who have a quotation that contains (this AND these) - which should return "Mr A" but not "Mr B", and so on. How can I achieve this?</p>
  
  <p>EDIT1:</p>
  
  <p>Andrei's answer below seems to work, with data values now looking like:</p>
  
  <pre><code>{"name":"Mr A","quotations":[{"value" : "quotation one, this and that and these"}, {"value" : "quotation two, those and that"}]}
  </code></pre>
  
  <p>However, I can't seem to get a query_string query to work. The following produces no results:</p>
  
  <pre><code>{
    "query": {
      "nested": {
        "path": "quotations",
        "query": {
          "query_string": {
              "default_field": "quotations",
              "query": "quotations.value:this AND these"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Is there a way to get a query_string query working with a nested object?</p>
  
  <p>Edit2: Yes it is, see Andrei's answer.</p>