【发布时间】:2020-01-08 16:57:14
【问题描述】:
我正在使用:
- 弹性搜索:6.4.3
- Spring Boot:2.1.9.RELEASE
- Spring Elasticsearch:6.4.3
我在 ES 中有一个索引:
{
"mapping": {
"logi_info_index": {
"properties": {
"area": {
"type": "text"
},
"createdBy": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"createdDate": {
"type": "long"
},
"logiCode": {
"type": "integer"
},
"esId": {
"type": "keyword" -> @Id for ES
},
"geoPoint": {
"type": "geo_point"
},
"isActive": {
"type": "text"
},
"latitude": {
"type": "text"
},
"longitude": {
"type": "text"
},
"storeAddress": {
"type": "text"
},
"storeName": {
"type": "text"
},
"updatedBy": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"updatedDate": {
"type": "long"
}
}
}
}
}
现在,在这个索引中可能有大约 50K 文档。
对于某些业务逻辑,我需要更新所有满足特定条件的文档:isActive=0。
例子:
我们有文件,其中有isActive as 0 or 1。
- 删除所有具有
isActive = 1的文档 [=> 这可以通过DeleteQuery(deleteAll) - 由于现在我们只有
isActive = 0,我们想用isActive = 1更新剩余的文档。
我有以下问题:
- 我如何更新所有具有特定字段值的文档,不使用 Id(就像我在删除中所做的那样)?
- 这可能吗?
- 如果可能的话,我想利用 Spring 的能力来实现它。
【问题讨论】:
标签: spring elasticsearch spring-data-elasticsearch