ElasticSearch按查询删除不起作用

问题描述 投票:0回答:1

我正在尝试从ID大于1500001的索引中删除文档。我已经从弹性文档中复制了代码,但是没有给我任何结果。代码是

POST /us_data_master/_delete_by_query

{
  "query": {
    "range" : {
        "id" : {
           "gte" : 1500001
        }
    }
  }
}

我得到的答复是

{
   "error" : {
        "root_cause" : [
          {
            "type" : "action_request_validation_exception",
            "reason" : "Validation Failed: 1: query is missing;"
          }
        ],
        "type" : "action_request_validation_exception",
        "reason" : "Validation Failed: 1: query is missing;"
      },
      "status" : 400
    }

我不明白是什么问题。期待帮助

谢谢

编辑1:

所要求的映射是

 {


"mapping": {
    "_doc": {
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "@version": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "address": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "city_code": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "contact_no": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "date_added": {
          "type": "date"
        },
        "date_updated": {
          "type": "date"
        },
        "featured": {
          "type": "long"
        },
        "id": {
          "type": "long"
        },
        "location_id": {
          "type": "long"
        },
        "main_cate": {
          "type": "long"
        },
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "slug": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "source": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "state_code": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "status": {
          "type": "long"
        },
        "zip_code": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    }
  }
}
elasticsearch querydsl
1个回答
1
投票

我猜您正在使用Kibana。 POST和查询之后还有一个空行,如下所示:

POST /us_data_master/_delete_by_query
                                              <------ Remove this space
{
  "query": {
    "range" : {
        "id" : {
           "gte" : 1500001
        }
    }
  }
}

下面是应该如何:

POST /us_data_master/_delete_by_query
{
  "query": {
    "range" : {
        "id" : {
           "gte" : 1500001
        }
    }
  }
}

这应该可以解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.