# Search all indexes for document's parameter name or retrieve one document p/index

**URL:** <https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175>\
**Category:** Elasticsearch\
**Created:** [February 9, 2023, 4:27pm UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175 "2023-02-09T16:27:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunofl](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@brunofl](https://discuss.elastic.co/u/brunofl)\
**Post date:** [February 9, 2023, 4:27pm UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175/1 "2023-02-09T16:27:24Z")

</div>

Hi I am a bit new in elastic and started in a project that has more than 800 indexes and I need to rename some old names to the new ones requested.  
I already found some indexes that has parameters with values that need rename.

1. Is it possible to run a query on all indexes and retrieve one document per index?

2. What would be a good approach to rename the values in a index based on a list of current and desired values with 80 values to be renamed?

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 10, 2023, 2:27am UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175/2 "2023-02-10T02:27:04Z")

</div>

Welcome to our community! 😃

1. What's the goal of doing this?
2. What version of Elasticsearch are you using?

---

<div class="post-metadata">

**Author:** ![brunofl](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@brunofl](https://discuss.elastic.co/u/brunofl)\
**Post date:** [February 10, 2023, 11:57am UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175/3 "2023-02-10T11:57:52Z")

</div>

Hey Mark,  
Thanks for replying.  
1 - The main goal is:  
context: As some (80) of the access points from a provider model were renamed in our CMDB system, to get the data right, the **monitoring tool will be renamed soon** , the names in the existing indice's docs fields also needs to be updated so this doesn't impact the metrics in the dashboards.  
In the code that feeds elastic I already identified 28 indexes to be renamed, but we have a lot of indices with ML and other stuff, that I want to be sure which indice's have docs that needs to be updated and the field names if different from the 3 ones I already identified.  
2

```auto
"version" : {
    "number" : "7.13.4",
    "build_flavor" : "default",
    "build_type" : "docker",
     ...
    "build_snapshot" : false,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
}

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 14, 2023, 3:49am UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175/4 "2023-02-14T03:49:35Z")

</div>

Would [Alias field type | Elasticsearch Guide [7.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/field-alias.html) help?

---

<div class="post-metadata">

**Author:** ![brunofl](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@brunofl](https://discuss.elastic.co/u/brunofl)\
**Post date:** [February 17, 2023, 10:08pm UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175/5 "2023-02-17T22:08:08Z")

</div>

No, not really, a synonyms for each of the values I need to rename could work best for the use case, but we would not like to change the queries or reindex the documents.

I managed to do an update\_by\_query script with elasticsearch\_dsl.

```auto
response = ubq.script(source="pm_data_source.hw_alias' = params.new_ap_name",lang="painless",params={"new_ap_name": new_ap})\
        .query("match", pm_data_source.hw_alias = old_ap ).execute()

```

Current problem is: in the `query()` I am unable to match fields inside an object. Do you happen to know how to do this?

---

<div class="post-metadata">

**Author:** ![brunofl](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@brunofl](https://discuss.elastic.co/u/brunofl)\
**Post date:** [February 28, 2023, 10:48pm UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175/6 "2023-02-28T22:48:31Z")

</div>

> [@brunofl](#):
>
> Is it possible to run a query on all indexes and retrieve one document per index?

I managed to solve this by using the \_mapping api set like this:

`GET */_mapping/field/<field-to-look-for>`  
can also use \* with field name in case to match more then one fields with name patterns

It returns the mapping of all the indexes that contain the field name. Than you can import it on python or do some data cleaning with your IDE.

For the other issue in update by query I replied here: in this [separate post](https://discuss.elastic.co/t/update-by-query-in-elasticsearch-dsl-matches-field-but-doesnt-match-object-field/325889/2) while looking for help.

---

<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:** [March 28, 2023, 10:49pm UTC](https://discuss.elastic.co/t/search-all-indexes-for-documents-parameter-name-or-retrieve-one-document-p-index/325175/7 "2023-03-28T22:49:21Z")

</div>

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