# Spring-data-opensearch rename the indexName in @Document

**URL:** https://forum.opensearch.org/t/spring-data-opensearch-rename-the-indexname-in-document/22843
**Category:** OpenSearch
**Created:** [December 18, 2024, 6:49am UTC](https://forum.opensearch.org/t/spring-data-opensearch-rename-the-indexname-in-document/22843 "2024-12-18T06:49:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![som](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@som](https://forum.opensearch.org/u/som)
#### Post date: [December 18, 2024, 6:49am UTC](https://forum.opensearch.org/t/spring-data-opensearch-rename-the-indexname-in-document/22843/1 "2024-12-18T06:49:11Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
OS 2.18/OSX 14.6 M1

Spring-boot 3.3.3  
spring-data-opensearch 1.5.3

**Describe the issue** :

I want to be able to pass the indexName in @Document annotation, but want the actual index to be created with a prefix. What’s the way to do this using spring-data-opensearch?

example:  
@Document(indexName = “my-index”)  
public class MyEntity {  
private String prop;  
}

normally this will create an index named my-index - but I want to scan the @Document annotations present in the applications, extract the indexName - and apply a common prefix say “.prefix\_” to them all before they are created in Opensearch. So the resulting indexname in OS looks like ".prefix\_my-index "

Is there a way to achieve this

---

<div class="post-metadata">

### Author: ![reta](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@reta](https://forum.opensearch.org/u/reta)
#### Post date: [December 18, 2024, 5:32pm UTC](https://forum.opensearch.org/t/spring-data-opensearch-rename-the-indexname-in-document/22843/2 "2024-12-18T17:32:57Z")

</div>

The`@Document` annotation needs the concrete index name, if you want the index name to be dynamic, it will require manual index management. As an option, you could use index templates [1] to add aliases (like` prefix_my-index`) to the indices.

[1] [Index templates - OpenSearch Documentation](https://opensearch.org/docs/latest/im-plugin/index-templates/)
