# Spring elasticsearch - how to generate mapping for all the fields statically?

**URL:** <https://discuss.elastic.co/t/spring-elasticsearch-how-to-generate-mapping-for-all-the-fields-statically/318165>\
**Category:** Elasticsearch\
**Created:** [November 4, 2022, 7:13am UTC](https://discuss.elastic.co/t/spring-elasticsearch-how-to-generate-mapping-for-all-the-fields-statically/318165 "2022-11-04T07:13:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Java2avaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/java2avaj/32/99497_2.png) [@Java2avaj](https://discuss.elastic.co/u/Java2avaj)\
**Post date:** [November 4, 2022, 7:13am UTC](https://discuss.elastic.co/t/spring-elasticsearch-how-to-generate-mapping-for-all-the-fields-statically/318165/1 "2022-11-04T07:13:32Z")

</div>

I have a Person class:

```auto
@Document(indexName = "person")
@Data
@EqualsAndHashCode(callSuper = true)
public class Person extends BaseEntity implements Serializable {

  @Field(type=FieldType.Keyword)
  private String firstName;

  @Field(type=FieldType.Keyword)
  private String lastName;

  @MultiField(
      mainField = @Field(type = FieldType.Keyword),
      otherFields = {
          @InnerField(type = FieldType.Text, suffix = "ngrams", analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
      })
  private String fullName;

  @Field
  private String maidenName;
}

```

I have an existing code that creates an index during startup:

```auto
final IndexOperations indexOperations = this.elasticsearchOperations.indexOps(clazz);
      indexOperations.putMapping();

```

Now, I have a requirement to generate mappings from it and create mappings once. Can somebody help how can I integrate it with the existing code to include mappings of the fields to make them static?

---

<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:** [December 2, 2022, 7:14am UTC](https://discuss.elastic.co/t/spring-elasticsearch-how-to-generate-mapping-for-all-the-fields-statically/318165/2 "2022-12-02T07:14:10Z")

</div>

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