title: How to properly write boolean or logic in elasticsearch?
body: <p>I want to grab all documents with <code>loId=6</code> <strong>AND</strong> <code>(actionType = "SAVE_DATA"</code> <strong>OR</strong> <code>actionType = "OPEN_SCREEN")</code>.</p>
  
  <p><strong>Am I writing this logic incorrectly?</strong></p>
  
  <p><strong>Why does my query return 0 results?</strong></p>
  
  <p><strong>Note</strong>: I'd accept a query or a filter to resolve this issue.</p>
  
  <p>These are some sample documents:</p>
  
  <pre><code> {
      "_index": "logs",
      "_type": "record",
      "_id": "eIIt3vtrSxmdOVGClQmN3w",
      "_score": 1,
      "_source": {
         "timestamp": 1373569919000,
         "uid": 6,
         "paId": 56298,
         "loId": 6,
         "prId": 2,
         "vId": 6577,
         "actionType": "SAVE_DATA"
      }
   },
   {
      "_index": "logs",
      "_type": "record",
      "_id": "yQGCia6qRYCImZLyH7DrEA",
      "_score": 1,
      "_source": {
         "timestamp": 1373570314000,
         "uid": 6,
         "paId": 56641,
         "loId": 6,
         "prId": 2,
         "vId": 6578,
         "actionType": "CHECK_IN"
      }
   },
   {
      "_index": "logs",
      "_type": "record",
      "_id": "2raajrNKTKeRKG88wiNPpw",
      "_score": 1,
      "_source": {
         "timestamp": 1373570532000,
         "uid": 6,
         "paId": 56641,
         "loId": 6,
         "prId": 2,
         "vId": 6579,
         "actionType": "LOAD_DATA"
      }
   },
   {
      "_index": "logs",
      "_type": "record",
      "_id": "0FDBxW2ESl6tfmj81YJvIg",
      "_score": 1,
      "_source": {
         "timestamp": 1373570761000,
         "uid": 6,
         "paId": 56298,
         "loId": 6,
         "prId": 2,
         "vId": 6577,
         "actionType": "OPEN_SCREEN"
      }
   },
   {
      "_index": "logs",
      "_type": "record",
      "_id": "-bFQyEdCQVWiXNldtxz04g",
      "_score": 1,
      "_source": {
         "timestamp": 1373570777000,
         "uid": 6,
         "paId": 56298,
         "loId": 6,
         "prId": 2,
         "vId": 6577,
         "actionType": "OPEN_SCREEN"
      }
   }
  </code></pre>
  
  <p><strong>Query</strong></p>
  
  <pre><code>{
     "query": {
        "filtered": {
            "query": {
                "term": {
                      "loId": 6
                }
            }, 
           "filter": {
              "or": {
                 "filters": [
                    {
                       "term": {
                          "actionType": "SAVE_DATA"
                       }
                    },
                    {
                       "term": {
                          "actionType": "OPEN_SCREEN"
                       }
                    }
                 ],
                 "_cache": false
              }
           }
        }
     }
  }
  </code></pre>