java.lang.NoSuchFieldError: INDEX_CONTENT_TYPE error
Elasticsearch Version: 7.16.2
// elasticsearch
implementation 'org.springframework.data:spring-data-elasticsearch:4.3.0'
implementation 'org.elasticsearch:elasticsearch:7.16.2'
implementation 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.16.2'
// jackson-core
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.1'
public <T> void bulk(String indexName, List<T> documents, Class<T> tClass) {
elasticsearchIndex.setIndexName(indexName);
List<IndexQuery> queries = new ArrayList<>();
for (T document : documents) {
IndexQuery query = new IndexQueryBuilder()
.withObject(document)
.build();
queries.add(query);
}
IndexOperations indexOps = elasticsearchTemplate.indexOps(tClass);
if (!indexOps.exists()) {
indexOps.create();
indexOps.putMapping(indexOps.createMapping());
}
elasticsearchTemplate.bulkIndex(queries, tClass); // error
}
@Getter @Setter @ToString
@Document(indexName = "#{@elasticsearchIndex.getIndexName()}")
java.lang.NoSuchFieldError: INDEX_CONTENT_TYPE
remove gradle build
and add
implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch:2.6.2'
I experienced this same issue. I resolved it by downgrading Elastic Search and dependencies from 7.16
to 7.15
.
The current documentation shows that 7.15.2
is the highest version currently support (or tested for release).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.