Go 呼叫 elasticsearch 批量操作介面 “/_bulk” ,提示"\n"錯誤
問題如標題。
我已經按照文件的說明來進行操作了,但是還是提示錯誤。求解。謝謝。
文件
https://www.bookstack.cn/read/elasticsearch-definitive-guide-cn/030_Data-55_Bulk.md
我的原始碼
package main
import (
"fmt"
"strings"
"github.com/astaxie/beego/httplib"
)
func main() {
api := "http://localhost:9200/_bulk"
body := []string{
`{ "index": { "_index": "testbulk", "_type": "fulltext","_id":1 }}`,
`{ "title": "My second blog post 1" }`,
`{ "index": { "_index": "testbulk", "_type": "fulltext","_id":2 }}`,
`{ "title": "My second blog post 2" }`,
`{ "index": { "_index": "testbulk", "_type": "fulltext","_id":3 }}`,
`{ "title": "My second blog post 3" }`,
}
str := strings.Join(body, "\n")
fmt.Println(str)
resp, err := httplib.Post(api).Header("Content-Type", "application/json").Body(str).String()
fmt.Println(resp, err)
}
提示的錯誤
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\n]"}],"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\n]"},"status":400} <nil>
更多原創文章乾貨分享,請關注公眾號
- 加微信實戰群請加微信(註明:實戰群):gocnio
相關文章
- mongodb批量操作, bulk_write,MongoDB
- ElasticSearch7.4批量匯入_bulkElasticsearch
- ELK研究(一):elasticsearch java api介面操作ES叢集 ---TransportClient的使用介紹 bulk批量提交資料ElasticsearchJavaAPIclient
- elasticsearch bulk資料--ES批量匯入json資料ElasticsearchJSON
- go"繼承"Go繼承
- go操作elasticsearch示例GoElasticsearch
- Elasticsearch——mget及bulkElasticsearch
- Elasticsearch的Bulk API使用ElasticsearchAPI
- Xamarin Android設定介面提示型別錯誤Android型別
- 資訊批量提取工具bulk-extractor
- Go 快速入門指南 - 實現系統錯誤介面Go
- 109.全文檢索-ElasticSearch-入門-刪除資料&bulk批量操作匯入樣本測試資料Elasticsearch
- 【有碼】go併發操作map的錯誤用例Go
- 讀 "優雅關閉的 Go Web 伺服器"GoWeb伺服器
- 使用BULK COLLECT+FORALL加速批量提交
- Go 錯誤處理Go
- Laravel 54 配置 Elasticsearch 時的報錯提示LaravelElasticsearch
- Nessus提示API Disabled錯誤API
- HTTP錯誤提示資訊表HTTP
- 使用bulk collect實現cursor 批量fetch!
- Elasticsearch報Call to undefined xx makeAllSearchable()錯誤ElasticsearchUndefined
- 呼叫HMS SDK介面報錯6004
- go的錯誤處理Go
- 使用Go呼叫第三方介面Go
- onethink安裝提示錯誤
- 安裝golang tour,提示錯誤Golang
- 如何關閉PHP錯誤提示PHP
- 請教執行錯誤提示
- SQL Server Bulk Insert批量資料匯入SQLServer
- ElasticSearch實戰系列十一: ElasticSearch錯誤問題解決方案Elasticsearch
- laravel mysql批量提交報Access denied 錯誤LaravelMySql
- 【elasticsearch】bulk api奇特的json格式的原因ElasticsearchAPIJSON
- 【go】【Elasticsearch】GoElasticsearch
- 呼叫HMS SDK介面報錯6003
- go語言呼叫everything的SDK介面Go
- html:text property="ABoolean"輸出是"on"HTMLBoolean
- Go語言之錯誤處理Go
- MySQL錯誤提示(10061)MySql