elasticsearch - 向 Elasticsearch 服务器发送 curl 请求时,不支持错误application/x-www-form-urlencoded

标签 elasticsearch curl

我正在尝试将一些数据发布到 flex 搜索服务器。我为此使用curl。代码是:

curl -X PUT https://username:password@someurl:443/index_name?pretty -H 'Content-Type: application/json' -d  ' {"mappings": {"properties": {"my_field": {"type": "search_as_you_type"}}}}'

只有通过cat/_indices?v检索索引信息的基本内容才有效

错误包括
"Content-Type header [application/x-www-form-urlencoded] is not supported", curl: (6) Could not resolve host: application
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 19

最佳答案

很明显,错误消息表明您在错误消息的第一行中使用了错误的内容类型application/x-www-form-urlencoded

"Content-Type header [application/x-www-form-urlencoded] is not supported",



由于给定的映射似乎是从官方ES https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-as-you-type.html链接复制而来的,因此只有您可以找到相应的CURL格式。

粘贴该格式以及链接中的屏幕截图,如何复制整个curl命令。

copy as curl in circle
在这里,我在本地尝试过并成功了,请注意,唯一的区别是内容类型应该为application/json
curl -X PUT "localhost:9500/so_index?pretty" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "my_field": {
        "type": "search_as_you_type"
      }
    }
  }
}
'

关于elasticsearch - 向 Elasticsearch 服务器发送 curl 请求时,不支持错误application/x-www-form-urlencoded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59677443/

相关文章:

sorting - 在 Elasticsearch 中如何按两个日期中较小的一个进行排序?

json - 在couchdb中使用elasticsearch索引json中的名称

linux - 使用 CURL 上传到 Dropbox 并覆盖文件

curl - js_of_ocaml : missing primitive when calling ocurl and str

elasticsearch - 配置ElasticClient连接池

c# - 无法使用NEST 1.2.0激活跟踪

elasticsearch - 按字段值对文档进行分组

curl - 使用cURL崩溃

php - 附加值 1 附加了 curl 响应

php - 从 php curl https 请求中删除 SCSV Cipher Suite