Testcontainers ES 7 - тип отсутствует в массовом запросе

Я использую testcontainers, чтобы проверить свое взаимодействие с Elasticsearch 7. Этот код работает в AWS с ES 7, но у меня возникает проблема, когда я хочу протестировать его с помощью testcontainers:

// Docker image
// I tried with a lot of versions 5, 6 and 7 and I'm getting the same error
private ElasticsearchContainer container = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.5.2");

// client dependecy
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.5.2</version>
    </dependency>

// here is the bulk 
RestHighLevelClient restHighLevelClient;
BulkRequest bulkRequest = RequestBuilder.build(MymodelClass, indexName);
BulkResponse bulkResponse = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);

            // If I try this it shows
            for (DocWriteRequest docWriteRequest: bulkRequest.requests()) { 
                System.out.println("index ", docWriteRequest.index());
                System.out.println("opType ", docWriteRequest.opType().getLowercase());
                System.out.println("type ", docWriteRequest.type());
            }
            // index myIndexName
            // opType index
            // type _doc


// This is the error that I'm getting:
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://localhost:9200], URI [/_bulk?timeout=1m], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"},"status":400}

Я читал кое-что о свойстве include_type_name, которое по умолчанию является ложным, но не знаю, как установить его как истинное с помощью restHighLevelClient. Кроме того, как я уже сказал, он работает в AWS с ES 7. Я хочу добавить несколько модульных тестов с помощью testcontainers. Есть идеи? Спасибо

0 ответов

Другие вопросы по тегам