# Querying from multiple indices

**URL:** <https://discuss.elastic.co/t/querying-from-multiple-indices/130125>\
**Category:** Elasticsearch\
**Created:** [May 1, 2018, 1:56pm UTC](https://discuss.elastic.co/t/querying-from-multiple-indices/130125 "2018-05-01T13:56:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dangal](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dangal](https://discuss.elastic.co/u/dangal)\
**Post date:** [May 1, 2018, 1:56pm UTC](https://discuss.elastic.co/t/querying-from-multiple-indices/130125/1 "2018-05-01T13:56:39Z")

</div>

Hi All,

```auto
GET pk,dangal/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "user": "kimchy" }},
        { "match": { "format": "text" }}
      ]
    }
  }
}

```

in the above query you can see that  
In index pk had the term "user": "kimchy" in one document  
in index dangal had the term "format": "text" in one document  
now i want those two documents as output.......i must use AND condition

if i use should i am getting output but that checks OR condition

```auto
GET pk,dangal/_search
{
  "query": {
    "bool": {
      "should": [
        { "match": { "user": "kimchy" }},
        { "match": { "format": "text" }}
      ]
    }
  }
}

```

output

```auto
{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 10,
    "successful": 10,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 0.2876821,
    "hits": [
      {
        "_index": "pk",
        "_type": "_doc",
        "_id": "2",
        "_score": 0.2876821,
        "_source": {
          "user": "kimchy",
          "post_date": "2009-11-15T14:12:12",
          "message": "trying out Elasticsearch"
        }
      },
      {
        "_index": "dangal",
        "_type": "_doc",
        "_id": "3",
        "_score": 0.2876821,
        "_source": {
          "user": "gilbert3",
          "post_date": "2010-11-15T14:12:12",
          "message": "trying out logstash",
          "format": "text"
        }
      }
    ]
  }
}

```

i want the same output with AND condition that is with must

I appreciate quick response

Thank You

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 1, 2018, 2:11pm UTC](https://discuss.elastic.co/t/querying-from-multiple-indices/130125/2 "2018-05-01T14:11:14Z")

</div>

I am not sure I understand. You do not have any document that matches both conditions you are looking for, which is why I assume the query with the `must` (AND) condition does not return anything.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 29, 2018, 2:11pm UTC](https://discuss.elastic.co/t/querying-from-multiple-indices/130125/3 "2018-05-29T14:11:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
