title: multiple search conditions in one query in es and distinguish the items according to the conditions
body: <p>For one case I need to put multiple search conditions in one query to reduce the number of queries we need.</p>
  
  <p>However, I need to distinguish the returning items based on the conditions.</p>
  
  <p>Currently I achieved this goal by using function score query, specifically: each condition is assigned with a score, and I can differentiate the results based on those scores.</p>
  
  <p>However, the performance is not that good. Plus now we need to get the doc count of each condition.</p>
  
  <p>So is there any way to do it? I'm thinking using aggregation, but not sure if I can do it.</p>
  
  <p>Thanks!</p>
  
  <p>update: </p>
  
  <pre><code>curl -X GET 'localhost:9200/locations/_search?fields=_id&amp;from=0&amp;size=1000&amp;pretty' -d '{
  "query":{
    "bool":{
      "should":[
        {
          "filtered":{
            "filter":{
              "bool":{
                "must":[{"term":{"city":"new york"}},{"term":{"state":"ny"}}]
              }
            }
          }
        },
        {
          "filtered":{
            "filter":{
              "bool":{
                "must":[{"term":{"city":"los angeles"}},{"term":{"state":"ca"}}]
              }
            }
          }
        }
      ]
    }
  }}'
  </code></pre>