1

I'm having this issue where I need my index to look like this:

"status": {
     "type": "keyword",
} 

I create my Java class:

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@Document(indexName = "#{applicationConfiguration.indexName}")
public class ProductDocument {

    @Field(type = FieldType.Keyword)
    @NotEmpty
    @JsonProperty("status")
    private String status;

}

But spring creates the index as follows:

"status": {
     "type": "text",
     "fields": {
          "keyword": {
               "type": "keyword",
               "ignore_above": 256
          }
      }
}

How can I make the keyword type the main type instead text?

  • Does this answer your question? [How to define ElasticSearch index field names for a POJO using Spring Data ElasticSearch](https://stackoverflow.com/questions/28839023/how-to-define-elasticsearch-index-field-names-for-a-pojo-using-spring-data-elast) – pringi Mar 16 '21 at 12:36
  • Thanks, but it is not the same question. – Everis Souza Mar 16 '21 at 13:19
  • How do you access Elasticsearch with Spring Data? via repositories or `ElasticsearchRestTemplate`? either way, are you sure about their configuration? – glenacota Mar 21 '21 at 10:28

0 Answers0