2

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

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Instead of downgrading Elastic version, is there any other way to fix this error? Thanks
0

The problem you faced has been fixed in version 4.4.0 which supports elasticsearch 7.17.3.

Check https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#new-features.4-4-0

1.1. New in Spring Data Elasticsearch 4.4

  • ...
  • Upgrade to Elasticsearch 7.17.3.

Comments

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.