gpt4 book ai didi

elasticsearch - Elasticsearch POST/delete_by_query不起作用

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

我试图使用POST / delete_by_query在Elasticsearch中删除文档,但是在执行时并没有删除文档,但是没有引发错误。有趣的是,它适用于某些索引,但不适用于其他索引。有什么原因会发生这种情况吗?

POST /my-index/_delete_by_query?slices=1&requests_per_second=-1&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&refresh=true&conflicts=proceed&wait_for_completion=true
{
"size": 1000,
"query": {
"bool": {
"must": [
{
"bool": {
"must": [
{
"terms": {
"myAttributeKey1": [
"myAttributeValue1"
],
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
{
"query_string": {
"query": "myAttributeValue2",
"fields": [
"myAttributeKey2"
],
"type": "best_fields",
"default_operator": "and",
"max_determinized_states": 10000,
"enable_position_increments": true,
"fuzziness": "AUTO",
"fuzzy_prefix_length": 0,
"fuzzy_max_expansions": 50,
"phrase_slop": 0,
"escape": false,
"auto_generate_synonyms_phrase_query": true,
"fuzzy_transpositions": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"_source": false
}

最佳答案

事实证明,索引映射是个问题。以下是索引映射。我应该使用myAttributeKey1.keyword而不是myAttributeKey1这个词,可以通过修复索引映射来解决。

{
"mapping": {
"_doc": {
"properties": {
"myAttributeKey1": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
这是您可能想要的映射的比较
{
"mapping": {
"_doc": {
"properties": {
"_class": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"myAttributeKey1": {
"type": "keyword"
}
}
}
}
}

关于elasticsearch - Elasticsearch POST/delete_by_query不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64026608/

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