0

How can I set all text fields fielddata true using java and elasticsearch? I want to sort products using a field from features. However features is a dynamic object, I can't predicate what will be its keys. The problem is how to set all features attributes fielddata true. this is my model:

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;


@Document(indexName = "product", type = "product")
public class ProductSearchModel {

    @Id
    @Field(type = FieldType.Keyword, fielddata = true)
    private String id;

    @Field(type = FieldType.Nested , fielddata = true)
    private CategorySearchModel brand;

    @Field(type = FieldType.Text , fielddata = true)
    private String code;

    private Object features;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

 

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getFeatures() {
        return features;
    }

    public void setFeatures(Object features) {
        this.features = features;
    }

   
}

1 Answers1

0

Can you parse the Object to a Map or a Json or something?.

If yes, run through its keys and set the value to true?

Examples:

onionknight
  • 101
  • 1
  • 10