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
- Elasticsearch——mget及bulkElasticsearch
- go操作elasticsearch示例GoElasticsearch
- 讀 "優雅關閉的 Go Web 伺服器"GoWeb伺服器
- 109.全文檢索-ElasticSearch-入門-刪除資料&bulk批量操作匯入樣本測試資料Elasticsearch
- MySQL錯誤提示(10061)MySql
- WEBAPI單據查詢介面提示比較符67錯誤WebAPI
- Go 快速入門指南 - 實現系統錯誤介面Go
- Nessus提示API Disabled錯誤API
- onethink安裝提示錯誤
- Go 錯誤處理Go
- PbootCMS錯誤提示:執行SQL發生錯誤!錯誤:no such column: def1bootSQL
- 【elasticsearch】bulk api奇特的json格式的原因ElasticsearchAPIJSON
- 修正FIREFOX下批量上傳的錯誤Firefox
- laravel mysql批量提交報Access denied 錯誤LaravelMySql
- Laravel 54 配置 Elasticsearch 時的報錯提示LaravelElasticsearch
- 網站提示400錯誤:錯誤請求怎麼辦網站
- Elasticsearch報Call to undefined xx makeAllSearchable()錯誤ElasticsearchUndefined
- 安裝golang tour,提示錯誤Golang
- 如何關閉PHP錯誤提示PHP
- 呼叫HMS SDK介面報錯6004
- 呼叫HMS SDK介面報錯6003
- go語言呼叫everything的SDK介面Go
- go的錯誤處理Go
- sqlserver bulk insert報錯Cannot bulk load because the file could not be opened.SQLServer
- myeclipse中提示Hot Code Replace Failed提示窗錯誤EclipseAI
- ElasticSearch實戰系列十一: ElasticSearch錯誤問題解決方案Elasticsearch
- Go 常見錯誤集錦之 append 操作 slice 時的副作用GoAPP
- TCP網路除錯助手提示錯誤:“1035:未知錯誤” 解決方案TCP除錯
- Rust : RUST_BACKTRACE=1錯誤提示Rust
- dedecms提示500錯誤解決方法
- 0176-列印錯誤提示資訊
- Dedecms提示 ereg_replace() is deprecated 錯誤
- Nextcloud的一些錯誤提示Cloud
- apache提示錯誤:httpd-ahssl.confApachehttpd
- 使用Go呼叫第三方介面Go
- PHP 介面呼叫報錯 502 Bad GatewayPHPGateway