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

I have a Person class:

@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:

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?

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