1

I am using the Elasticsearch's 8.x Java API client for indexing documents to Elasticsearch. While indexing, I'm specifying an ingest pipeline to be executed during data ingestion.

public Mono<IndexResponse> addContent(RequestDoc requestDoc) {
        IndexRequest<ContentTransformedModel> indexRequest = IndexRequest.of(request -> request
                .index("test-index")
                .document(requestDoc)
                .pipeline("test-ingest-pipeline"));
        return reactiveElasticsearchClient.index(indexRequest)
                .onErrorResume(IOException.class,
                        e -> Mono.error(new ElasticsearchPublishException(ES_INDEX_INTERNAL_SERVER_ERROR, e)));
    }

I want to move this implementation to Spring data elasticsearch. Is it possible to configure ingest pipelines for indexing documents in Spring data elasticsearch?

5
  • 1
    Rather than considering about ingest pipeline you can use default.ingest_pipeline in index settings and it will affect each new indexing request. After put this settings, you just need to push the data. elastic.co/guide/en/elasticsearch/reference/current/… Commented Jun 11, 2024 at 10:51
  • Just to update, I went ahead with this approach. Commented Jul 19, 2024 at 7:33
  • Did it work? if so I will share it as an answer. Commented Jul 19, 2024 at 13:02
  • Yes it did work. Thanks. Commented Jul 24, 2024 at 11:12
  • 1
    Nice to hear that. Shared as an answer Commented Jul 24, 2024 at 19:08

2 Answers 2

1

Rather than considering about ingest pipeline you can use default.ingest_pipeline in index settings and it will affect each new indexing request. After put this settings, you just need to push the data. https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html#set-default-pipeline

PUT your_index_name/_settings
{
  "index.default_pipeline": "your_ingest_pipeline_name"
}
Sign up to request clarification or add additional context in comments.

Comments

1

I am not so sure but you can probably do it using the ElasticsearchRestTemplate, I believe that it should work, you can find it here:

https://docs.spring.io/spring-data/elasticsearch/docs/3.2.3.RELEASE/api/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.html

if it didn't work check the ElasticsearchOperations:

https://docs.spring.io/spring-data/elasticsearch/docs/current/api/org/springframework/data/elasticsearch/core/ElasticsearchOperations.html

but if you arrived at a dead end maybe this is the only way to do it:

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-ingest-put-pipeline.html

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.