# Cross index field getting queried?

**URL:** <https://discuss.elastic.co/t/cross-index-field-getting-queried/185215>\
**Category:** Elasticsearch\
**Created:** [June 11, 2019, 2:28pm UTC](https://discuss.elastic.co/t/cross-index-field-getting-queried/185215 "2019-06-11T14:28:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pokaleshrey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pokaleshrey/32/48680_2.png) [@pokaleshrey](https://discuss.elastic.co/u/pokaleshrey)\
**Post date:** [June 11, 2019, 2:28pm UTC](https://discuss.elastic.co/t/cross-index-field-getting-queried/185215/1 "2019-06-11T14:28:38Z")

</div>

I have two separate indices A and B. Both indices have their own document structure.

One field name is common between documents of A and B i.e. userName.

When i query

> POST /A/\_search  
> {  
> "term": {  
> "userName": "james"  
> }  
> }

What is the possibility that this query will also check for the documents on index B ??  
My expectation is, it should not go and check any document of index B.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 11, 2019, 2:39pm UTC](https://discuss.elastic.co/t/cross-index-field-getting-queried/185215/2 "2019-06-11T14:39:37Z")

</div>

No. It will query only `A`.

---

<div class="post-metadata">

**Author:** ![pokaleshrey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pokaleshrey/32/48680_2.png) [@pokaleshrey](https://discuss.elastic.co/u/pokaleshrey)\
**Post date:** [June 11, 2019, 2:40pm UTC](https://discuss.elastic.co/t/cross-index-field-getting-queried/185215/3 "2019-06-11T14:40:50Z")

</div>

Thanks @dadoonet .  
That will help me avoid querying a million docs 🙂

---

<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:** [July 9, 2019, 2:41pm UTC](https://discuss.elastic.co/t/cross-index-field-getting-queried/185215/4 "2019-07-09T14:41:03Z")

</div>

Closed on July 9, 2019, 2:41pm UTC

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