0

Given using annotation on both Class and fields levels to set my mappings settings and use settings file like this

@Setting(settingPath = "settings.json")

to define custom analyzers, how would I set mappings "dynamic": false ?

1 Answer 1

1

Setting the dynamic mapping type on document and objects was introduced in Spring Data Elasticsearch version 4.0.0. It can be defined like this (code from the tests):

@Document(indexName = "test-index-configure-dynamic-mapping")
@DynamicMapping(DynamicMappingValue.False)
class ConfigureDynamicMappingEntity {

    @Nullable 
    @DynamicMapping(DynamicMappingValue.Strict) 
    @Field(type = FieldType.Object) 
    private Author author;

    @Nullable
    public Author getAuthor() {
        return author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

do you have link for the whole repo?
The library is available in maven/gradle, the repo is at github.com/spring-projects/spring-data-elasticsearch. Make sure you use the right versions of Elasticsearch and possibly Spring Bott (see docs.spring.io/spring-data/elasticsearch/docs/4.0.1.RELEASE/…)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.