Elasticsearch Ingest API

Elasticsearch Ingest is a feature that allows you to preprocess documents before indexing them. It consists of a pipeline of processors that can manipulate the contents of the documents.

One way to test the effectiveness of an Ingest pipeline is to simulate its execution on a sample document. This can be done using the Elasticsearch Ingest API's "simulate" endpoint.

To use the "simulate" endpoint, you need to provide a JSON object that represents the document you want to test, and a JSON object that represents the pipeline you want to simulate. Here is an example of how to use the "simulate" endpoint:

curl -H 'Content-Type: application/json' -XGET 'localhost:9200/_ingest/pipeline/_simulate' -d '{
  "pipeline": {
    "description": "Sample pipeline",
    "processors": [
      {
        "set": {
          "field": "foo",
          "value": "bar"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "text": "Hello world"
      }
    }
  ]
}'

In this example, we are simulating a pipeline that sets the value of the "foo" field to "bar" for every document that passes through it. We are testing this pipeline on a single document that contains the text "Hello world".

The response from the "simulate" endpoint will show you the resulting document after it has been processed by the pipeline:

{
  "docs" : [
    {
      "doc" : {
        "_index" : "_index",
        "_type" : "_doc",
        "_id" : "_id",
        "_source" : {
          "foo" : "bar",
          "text" : "Hello world"
        },
        "_ingest" : {
          "timestamp" : "2023-03-30T14:12:00.000Z"
        }
      }
    }
  ]
}

As you can see, the resulting document now contains the "foo" field with the value "bar", which indicates that the pipeline was executed successfully.

댓글

이 블로그의 인기 게시물

Sparse encoder

To build a gRPC service with Gradle, Java, and Avro

Using venv in Python

how to delete doc of datastream in elasticsearch, 엘라스틱서치 데이터스트림 도규먼트 삭제하기

Typescript interface, 타입스크립트 인터페이스

Read a file in Java, 자바 파일 읽기

kubernetes cronjob logs

max_active_runs of Airflow

configure telnet server, 텔넷 서버 설정하기

To download a file from MinIO using Spring Boot, 스프링부트 Minio 사용하기