# Handling ambiguous field names in search query

**URL:** <https://discuss.elastic.co/t/handling-ambiguous-field-names-in-search-query/329941>\
**Category:** Elasticsearch\
**Created:** [April 13, 2023, 3:28pm UTC](https://discuss.elastic.co/t/handling-ambiguous-field-names-in-search-query/329941 "2023-04-13T15:28:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![denvaar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/denvaar/32/115774_2.png) [@denvaar](https://discuss.elastic.co/u/denvaar)\
**Post date:** [April 13, 2023, 3:28pm UTC](https://discuss.elastic.co/t/handling-ambiguous-field-names-in-search-query/329941/1 "2023-04-13T15:28:57Z")

</div>

I have a query that I run against multiple indices. Some of the indices being searched share some common field names, and I'm not sure what the best way to differentiate between them would be.

I can get the desired result by doing a series of boolean queries, using a term query for `_index` with the desired index that I want the sub queries to fall under, but I'm wondering if this is an anti-pattern, or if it's terrible for performance.

---

<div class="post-metadata">

**Author:** ![denvaar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/denvaar/32/115774_2.png) [@denvaar](https://discuss.elastic.co/u/denvaar)\
**Post date:** [April 27, 2023, 4:59pm UTC](https://discuss.elastic.co/t/handling-ambiguous-field-names-in-search-query/329941/2 "2023-04-27T16:59:25Z")

</div>

Solution was to take advantage of field aliases.

---

<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 25, 2023, 5:00pm UTC](https://discuss.elastic.co/t/handling-ambiguous-field-names-in-search-query/329941/3 "2023-05-25T17:00:23Z")

</div>

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