title: ElasticSearch filter by array item
body: <p>I have the following record in ES:</p>
  
  <pre><code>"authInput" : {
      "uID" : "foo",
      "userName" : "asdfasdfasdfasdf",
      "userType" : "External",
      "clientType" : "Unknown",
      "authType" : "Redemption_regular",
      "uIDExtensionFields" : 
      [
          {
              "key" : "IsAccountCreation",
              "value" : "true"
          }
      ],
      "externalReferences" : []
  }
  </code></pre>
  
  <p>"uIDExtensionFields" is an array of key/value pairs.  I want to query ES to find all records where:</p>
  
  <ol>
  <li>"uIDExtensionFields.key" = "IsAccountCreation"</li>
  <li>AND "uIDExtensionFields.value" = "true"</li>
  </ol>
  
  <p>This is the filter that I think I should be using but it never returns any data.</p>
  
  <pre><code>GET devdev/authEvent/_search
  {
     "size": 10,
      "filter": {
          "and": {
             "filters": [
                {
                    "term": {
                       "authInput.uIDExtensionFields.key" : "IsAccountCreation"
                    }
                },
                {
                 "term": {
                    "authInput.uIDExtensionFields.value": "true"
                 }   
                }
             ]
          }
      }
  }
  </code></pre>
  
  <p>Any help you guys could give me would be much appreciated.</p>
  
  <p>Cheers!</p>
  
  <p><strong>UPDATE: WITH THE HELP OF THE RESPONSES BELOW HERE IS HOW I SOLVED MY PROBLEM:</strong></p>
  
  <ol>
  <li>lowercase the value that I was searching for.  (changed "IsAccoutCreation" to "isaccountcreation")</li>
  <li>Updated the mapping so that "uIDExtensionFields" is a nested type</li>
  <li>Updated my filter to the following:</li>
  </ol>
  
  <p>_</p>
  
  <pre><code>GET devhilden/authEvent/_search
  {
     "size": 10,
     "filter": {
        "nested": {
           "path": "authInput.uIDExtensionFields",
           "query": {
              "bool": {
                 "must": [
                    {
                       "term": {
                          "authInput.uIDExtensionFields.key": "isaccountcreation"
                       }
                    },
                    {
                       "term": {
                          "authInput.uIDExtensionFields.value": "true"
                       }
                    }                  
                 ]
              }
           }
        }
     }
  }
  </code></pre>