I need to index all the fields of an Elasticsearch index when building the index, but after some time, if needed change the index
value to false and improve the performance by removing indexing from some of the fields.
As I searched, read the docs and tested it with spring data when I set index = false
after building the index in @Field
there is no change and the field is still searchable.
@Document(indexName = "book")
@Setting(refreshInterval = "30s", shards = 3)
class Book(
@Id
@Field(type = FieldType.Keyword)
var id: String? = null,
@Field(type = FieldType.Keyword )
var title: String? = null,
@Field(type = FieldType.Keyword,index = false)
val isbn: String)
I wanted to know if there is another solution to change the indexing of fields dynamically after building the index using spring data?
You'll need to run the modified program with a new index name to create a new index with the adjusted mapping and then manually do a reindexing from the old to the new index: Elasticsearch documentation about reindexing.