title: Filter with elasticsearch
body: <p>I want to fetch a range of date with a specific id, but my result is including other id's in it. I need help checking the query.</p>
  
  <p>This is what am trying to do</p>
  
  <p>Fectch all documents where <strong>uniqueid</strong> == 1 and
  <strong>start</strong> range from 2016-10-11T12:00:30.000Z
                       to "2016-10-12T12:00:30.000Z"</p>
  
  <p>My query and results is shown below.</p>
  
  <p><strong>Query</strong></p>
  
  <pre><code>GET _search
  
  {
  "query": {
      "constant_score": {
         "filter": {
             "bool": {
                 "must": [
                    {
                        "term": {
                           "uniqueid": 1
                        }
                    }
                 ],
                 "should": [
                    {
                      "range": {
                "start": {
                   "from": "2016-10-11T12:00:30.000Z",
                   "to": "2016-10-12T12:00:30.000Z"
                }
             }  
                    }
                 ]
             }
         }
      }
    }
  }
  </code></pre>
  
  <p><strong>Result</strong> </p>
  
  <pre><code>  {
     "took": 15,
     "timed_out": false,
     "_shards": {
     "total": 5,
     "successful": 5,
     "failed": 0
    },
     "hits": {
     "total": 6,
     "max_score": 1,
     "hits": [
       {
          "_index": "cdr",
          "_type": "face",
          "_id": "AVfDCsC-vh94Tg1hrkix",
          "_score": 1,
          "_source": {
             "start": "2016-10-12T12:00:30.000Z",
             "answer": "2016-10-12T12:00:25.000Z",
             "end": "2016-10-12T12:00:35.000Z",
             "duration": 50,
             "billsec": 55,
             "uniqueid": 1,
             "is_successful": true,
             "is_clicked": true
          }
       },
       {
          "_index": "cdr",
          "_type": "face",
          "_id": "AVfDCucPvh94Tg1hrkiy",
          "_score": 1,
          "_source": {
             "start": "2016-10-12T12:00:30.000Z",
             "answer": "2016-10-12T12:00:25.000Z",
             "end": "2016-10-12T12:00:35.000Z",
             "duration": 50,
             "billsec": 55,
             "uniqueid": 2,
             "is_successful": true,
             "is_clicked": true
          }
       },
       {
          "_index": "cdr",
          "_type": "face",
          "_id": "AVfDC1G2vh94Tg1hrkiz",
          "_score": 1,
          "_source": {
             "start": "2016-10-13T12:00:30.000Z",
             "answer": "2016-10-13T12:00:25.000Z",
             "end": "2016-10-13T12:00:35.000Z",
             "duration": 50,
             "billsec": 55,
             "uniqueid": 2,
             "is_successful": true,
             "is_clicked": true
          }
       },
       {
          "_index": "cdr",
          "_type": "face",
          "_id": "AVfDC2IGvh94Tg1hrki0",
          "_score": 1,
          "_source": {
             "start": "2016-10-13T12:00:30.000Z",
             "answer": "2016-10-13T12:00:25.000Z",
             "end": "2016-10-13T12:00:35.000Z",
             "duration": 50,
             "billsec": 55,
             "uniqueid": 1,
             "is_successful": true,
             "is_clicked": true
          }
       },
       {
          "_index": "cdr",
          "_type": "face",
          "_id": "AVfDCCOOvh94Tg1hrkiv",
          "_score": 1,
          "_source": {
             "start": "2016-10-10T12:00:15.000Z",
             "answer": "2016-10-10T12:00:25.000Z",
             "end": "2016-10-10T12:00:35.000Z",
             "duration": 25,
             "billsec": 25,
             "uniqueid": 1,
             "is_successful": true,
             "is_clicked": true
          }
       },
       {
          "_index": "cdr",
          "_type": "face",
          "_id": "AVfDCR2Uvh94Tg1hrkiw",
          "_score": 1,
          "_source": {
             "start": "2016-10-11T12:00:15.000Z",
             "answer": "2016-10-11T12:00:25.000Z",
             "end": "2016-10-11T12:00:35.000Z",
             "duration": 25,
             "billsec": 25,
             "uniqueid": 1,
             "is_successful": true,
             "is_clicked": true
              }
           }
        ]
     }
  }
  </code></pre>