尝试将数据POST到ElasticSearch服务器8.6,但出现错误”no handler found for uri”。

huangapple go评论54阅读模式
英文:

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

问题

我尝试使用CURL将数据发送到ElasticSearch服务器。有一个名为'datastream2'的索引,其字段类似于这样:

"datastream2": {
  "mappings": {
    "properties": {
      "UA": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 512
          }
        }
      },
      "accLang": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
      // 其他字段...
    }
  }
}

我想使用CURL将数据发送到这个索引。

我一直在尝试使用CURL进行POST操作,如下所示:

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"}'

但出现以下错误消息:

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

我承认我不确定在索引名称'/datastream2/'之后应该放什么,但我尝试了不同的值。一些文档说要列出类型(我不确定在哪里找到它),而一些文档说这在ElasticSearch 8+中已不再需要。

您有什么想法如何将这些数据发布到ElasticSearch中?

英文:

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?

答案1

得分: 1

你只需要将 newdocname 替换为 _doc,它就会起作用

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

英文:

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

huangapple
  • 本文由 发表于 2023年2月16日 14:13:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468471.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定