gpt4 book ai didi

elasticsearch - 如何在elasticsearch 2.3.0中删除字段?我用理性来查询

转载 作者:行者123 更新时间:2023-12-02 23:00:02 25 4
gpt4 key购买 nike

我使用以下命令在文档中插入了新字段wiki_collection并将其值设置为true:

POST /pibtest1/_update_by_query
{
"script": {
"inline": "ctx._source.wiki_collection=true"
},
"query": {
"match": {
"url":"http%3A%2F%2Fwww.searchtechnologies.com%2Fbundles%2Fmodernizr%3Fv%3D7-yR01kdRVQ7W1RQzMBVKYLDhCt0itEATWHixfzE8Os1"
}
}
}

但是现在我要删除此字段。我正在尝试这样做:
POST /pibtest1/_update
{
"script" : "ctx._source.remove(\"wiki_collection\")"
}

但我收到一条错误消息:
{
"error": {
"root_cause": [
{
"type": "invalid_type_name_exception",
"reason": "Document mapping type name can't start with '_'"
}
],
"type": "invalid_type_name_exception",
"reason": "Document mapping type name can't start with '_'"
},
"status": 400
}

还有其他方法可以在Elasticsearch中删除字段吗?

编辑:我已通过查询更新:
POST /pibtest1/_update_by_query
{
"script": {
"inline": "ctx._source.remove(\"wiki_collection\")"
},
"query": {
"match": {
"url": "http://www.searchtechnologies.com/bundles/modernizr?v=7-yR01kdRVQ7W1RQzMBVKYLDhCt0itEATWHixfzE8Os1"
}
}
}

但是现在我在文档中得到一个名为“remove ='wiki_collection'”的新文件,如下所示: http://i.stack.imgur.com/QvxIa.png
我想从我的文档中删除/删除此wiki_collection字段。

最佳答案

您的更新有误。它应该是(您指定完整路径-index / type / ID ):

POST /pibtest1/test/234/_update
{
"script": {
"inline": "ctx._source.remove(\"wiki_collection\")"
}
}

或者您使用相同的 _update_by_query :
POST /pibtest1/_update_by_query
{
"script": {
"inline": "ctx._source.remove(\"wiki_collection\")"
},
"query": {
"match": {
"url": "whatever"
}
}
}

关于elasticsearch - 如何在elasticsearch 2.3.0中删除字段?我用理性来查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37035971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com