Shady Ragab
Shady Ragab

Reputation: 725

spring data Elasticsearch dynamic mapping

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 ?

Upvotes: 0

Views: 1874

Answers (1)

Abacus
Abacus

Reputation: 19421

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;
    }
}

Upvotes: 1

Related Questions