title: How to search by array elements in elasticsearch?
body: <p>I have a document indexed in elasticsearch:</p>
  
  <pre><code>{
      "content":"Some content with @someone mention",
      "mentions":["someone"],
      "userId":"4dff31eaf8815f4df04e2d62"
  }</code></pre>
  
  <p>I try to find it with a query:</p>
  
  <pre><code>{
      "query": {
          "filtered": {
              "filter": { "term":{"userId":"4dff31eaf8815f4df04e2d62"} },
              "query": {
                  term: {"mentions":"someone"}
              }
          }
      }
  }</code></pre>
  
  <p>and receive no results.</p>
  
  <p>In the same time query for content works fine:</p>
  
  <pre><code>{
      "query": {
          "filtered": {
              "filter": { "term":{"userId":"4dff31eaf8815f4df04e2d62"} },
              "query": {
                  "term": {"content":"some"}
              }
          }
      }
  }</code></pre>
  
  <p>Is some special syntax required for search through arrays? I found several topics [<a href="http://elasticsearch-users.115913.n3.nabble.com/Search-inside-field-with-nested-array-td2293927.html">1</a>, <a href="http://elasticsearch-users.115913.n3.nabble.com/Query-Syntax-for-arrays-and-nested-objects-td212582.html">2</a>] about arrays in elasticsearch, but there is no direct answer.</p>
  
  <p><strong>UPD</strong> Get Mapping call returns the next result:</p>
  
  <pre><code>{
      "records": {
          "all":{
              "properties":{
                  "content":{"type":"string"},
                  "userId":{"type":"string"},
                  "mentions":{"type":"string"}
              }
          }
      }
  }</code></pre>
  
  <p><strong>UPD2</strong> I found the source of problem. I accidentally introduced an error into my question. The username I actually had in DB was in form "some_one" (underscore is significant). So standard index split it into 2 words and query for "some_one" of cause failing.</p>