Home > Software engineering >  Index a document into Elasticsearch
Index a document into Elasticsearch

Time:09-30

I am trying to index some data by using below command from elasticsearch https://www.elastic.co/guide/en/cloud/current/ec-working-with-elasticsearch.html:

curl -u USER:Password https://localhost:9200/my_index/_doc -XPOST -k 'Content-Type: application/json' -d '{ "title": "One", "tags": ["ruby"] }'

but I am getting error: {"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}curl: (3) URL using bad/illegal format or missing URL

Could anyone tell me what I am doing wrong or maybe tell me about how to do indexing.

CodePudding user response:

The Content-Type header needs to be passed with -H not -k

curl -u USER:Password https://localhost:9200/my_index/_doc -XPOST -k -H 'Content-Type: application/json' -d '{ "title": "One", "tags": ["ruby"] }'
                                                                     ^^
                                                                     ||

The rest is fine

CodePudding user response:

Try again without "-u" flag, because you already informed the user inside the url.

  • Related