bash - 在ElasticSearch批量上传中,如何插入带有单引号的数据?

标签 bash curl elasticsearch bulkinsert

如何将数据批量插入到其中包含单引号的ElasticSearch中?这是我正在尝试做的一个例子。

curl -XPUT 'http://localhost:9200/example1/example2/_bulk' -d'¬
{ "delete" : { "_id" : "1" } } ¬
{ "create" : { "_id" : "1" } } ¬
{ "name" : "John's House" }¬ '

最佳答案

您不能在单引号中嵌入单引号。
但是您可以中断单引号字符串,然后在其中“插入”单引号:

curl -XPUT 'http://localhost:9200/example1/example2/_bulk' -d'¬
{ "delete" : { "_id" : "1" } } ¬
{ "create" : { "_id" : "1" } } ¬
{ "name" : "John'\''s House" }'
                ^ ^^
                | ||
                | |└ start new single-quoted string
                | └- escaped single quote outside of single-quoted string
                └--- close previously started single-quoted string

关于bash - 在ElasticSearch批量上传中,如何插入带有单引号的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44468496/

相关文章:

c - 将 STDOUT 和 STDERR 重定向到 C 中的套接字?

c - 如何使用linux c计算bash中光标前的字母?

Linux非法日期格式

regex - 使用 sed 匹配模式并从该行删除到文件末尾

php - 如何在使用简单的 HTML Dom 解析器解析之前登录 Web 表单网站?

elasticsearch - 带有文档时间点的Elasticsearch日期直方图

php - 从 URL(自己网站的)获取 HTML 内容

curl - 通过curl从oracle网站下载weblogic安装包

elasticsearch - 如何按对象的子对象字段对对象进行排序?

elasticsearch - 无法从 Elasticsearch 获取 [data] 集群的许可证信息