# Prefix field with specific index name while searching on multiple indices

**URL:** <https://discuss.elastic.co/t/prefix-field-with-specific-index-name-while-searching-on-multiple-indices/274628>\
**Category:** Elasticsearch\
**Created:** [June 1, 2021, 12:14pm UTC](https://discuss.elastic.co/t/prefix-field-with-specific-index-name-while-searching-on-multiple-indices/274628 "2021-06-01T12:14:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dgame](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgame/32/89594_2.png) [@Dgame](https://discuss.elastic.co/u/Dgame)\
**Post date:** [June 1, 2021, 12:14pm UTC](https://discuss.elastic.co/t/prefix-field-with-specific-index-name-while-searching-on-multiple-indices/274628/1 "2021-06-01T12:14:39Z")

</div>

Let's say I have two different indices (`index_a` and `index_b`) which both have different fields. For example `index_a` has the field `title` and `body` and `index_b` has only the field `body`. Now I'm searching like this:

```json
{
  "query": {
    "simple_query_string" : {
        "query": "\"fried eggs\" +(eggplant | potato) -frittata",
        "fields": ["title^5", "body"],
        "default_operator": "and"
    }
  }
}

```

And that would search on `index_a` in the fields `title` and `body` and on `index_b` in the field `body`. But what if I only want to search in the field `body` of `index_b` and `title` of `index_a`?

I've tried to prefix the field names with `<index>.<field>` but of course that does not work. But is that somehow possible without using bool, must, exists etc. Queries? My desired syntax would be

```json
"fields": ["index_a.title^5", "index_b.body"]

```

or perhaps a bit more descriptive

```json
"fields": {"title": {"boost": 5, "index": "index_a"}, "body": {"boost": 1, "index": "index_b"}]

```

I hope you understand what I am trying to ask and that there is a nicer solution than working with deeply nested bool, must, exists queries.

---

<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:** [June 29, 2021, 12:15pm UTC](https://discuss.elastic.co/t/prefix-field-with-specific-index-name-while-searching-on-multiple-indices/274628/2 "2021-06-29T12:15:14Z")

</div>

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