简体   繁体   English

如何在Elasticsearch中指定版本类型

[英]How to specify version type in elasticsearch

I'm trying to index a document as shown below. 我正在尝试为文档编制索引,如下所示。

curl -s -XPUT -H"content-type:application/json" -d@data.json localhost:9200/contacts/_doc/1?version=7&version_type=external

Unfortunately this results in version conflict. 不幸的是,这导致版本冲突。 Elasticsearch documentation says that I should pass version_type as external when I use an external version. Elasticsearch文档说,当我使用外部版本时,我应该将version_type作为external传递。 But I'm not sure how to do this as its not supporting this as a query parameter. 但是我不确定如何执行此操作,因为它不支持将此作为查询参数。

How do I specify version_type as external? 如何将version_type指定为外部?

EDIT: current version of the document is 5. But according to es documentation , when version_type external is used, any higher version should work. 编辑:该文档的当前版本为5。但是根据es文档 ,当使用version_type external时,任何更高的版本都应该起作用。 Which means 7 should be able to overwrite 5. But as I'm getting version conflict I assume that es is not taking the version_type parameter that I'm specifying. 这意味着7应该可以覆盖5。但是当我遇到版本冲突时,我假设es没有采用我指定的version_type参数。

SOLVED: I had to put the URL given to curl in quotes. 已解决:我必须将给定的URL放在引号中。 Bash took the & in in URL, took rest of it as new command and set version_type as an environment variable. Bash将URL中的&引入,将其其余部分用作新命令,并将version_type设置为环境变量。

Your curl command looks correct. 您的curl命令看起来正确。 The conflict can come because of the different versions of the document. 冲突可能是由于文档版本不同而引起的。

I would guess that the current version of the document is not 7 and hence it throws the version conflict. 我猜该文档的当前版本不是7,因此会引发版本冲突。

Can you post the current version of this same document? 您可以发布同一文档的当前版本吗? Is it 7 ? 是7吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在elasticsearch管道中指定文档版本? - How to specify document version in elasticsearch pipeline? 如何在 spring-boot 中指定较新版本的 Elasticsearch - How to specify a newer version of Elasticsearch in spring-boot 如何从Elasticsearch Index 2.2版中删除所有类型的文档 - How to remove all documents of type from elasticsearch index version 2.2 Hibernate Search + Elasticsearch - 请求中的version_type - 如何实现 - Hibernate Search + Elasticsearch - version_type in requests - how to implement 在属性文件中的 elasticsearch 中指定 indexName 和索引类型 - Specify indexName and type of index in elasticsearch in a properties file 如何在 Elasticsearch 的查询或过滤器中指定或定位来自特定文档类型的字段? - How to specify or target a field from a specific document type in queries or filters in Elasticsearch? 如何在Elasticsearch中指定default-mapping.json - How to specify a default-mapping.json in Elasticsearch 如何指定不应在ElasticSearch中建立索引的字段 - How to specify fields which should not be indexed in ElasticSearch 如何在对 Elasticsearch 的 API 请求中指定租户? - How to specify tenant in API request to Elasticsearch? 如何使用nodejs elasticsearch客户端指定路由? - How to specify routing using nodejs elasticsearch client?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM