Trying to POST data to ElasticSearch server 8.6, but getting error "no handler found for uri"

Advertisements

I’m trying to send data to an ElasticSearch server using CURL. There is an index called ‘datastream2’ which has a lot of fields sorta like this:

"datastream2": {
"mappings": {
"properties": {
"UA": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 512
}
}
},
"accLang": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}…

I’d like to use CURL to send data to this index.

I’ve been using CURL for the attempted POST like this:

curl -v -X POST http://66-228-66-111.ip.linodeusercontent.com:9200/datastream2/newdocname -H "Content-type: application/json" –user elastic:u34XXXc2qYNGnVS4XXXA -d ‘{"UA":"Mozilla","acclang":"eng"}’

but it’s failing with the message:

{"error":"no handler found for uri [/datastream2/newdocname] and method [POST]"}%

I will admit that I’m not sure what to put after the indexname of ‘/datastream2/’ , but I’ve tried various different values. Some documentation says to list the type (which I’m not sure where to find) and some docs say that this is no longer necessary on ElasticSearch 8+ .

Any ideas how I can get this data posted into ElasticSearch?

>Solution :

You just need to replace newdocname by _doc and it will work

curl -v -X POST http://66-228-66-111.ip.linodeusercontent.com:9200/datastream2/_doc

Leave a ReplyCancel reply