elasticsearch - Elasticsearch POST/delete_by_query不起作用

标签 elasticsearch

我试图使用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/

相关文章:

python - 无法使用 Django Haystack : 'Connection refused' 重建索引 elasticsearch

elasticsearch - Elasticsearch同时排序

solr - 按词组搜索最常用的词组

elasticsearch - Elasticsearch查询更新时如何处理版本冲突

php - Laravel Elasticsearch 不给出包含或喜欢的匹配

elasticsearch - 在Elasticsearch中映射openNLP或StanfordNLP

elasticsearch - 压缩后的Elasticsearch http.max_content_length

elasticsearch - IndexTemplate 仅将别名分配给新创建的索引

ruby-on-rails - 轮胎 + Will_Paginate 不采用 Tire.options

java - 从 Java 中的 String 中删除长 unicode 术语