【发布时间】:2015-05-10 22:50:34
【问题描述】:
我正在使用 Grails 插件在 MySQL 上使用 ElasticSearch。我在我的域类中映射了一个域列,如下所示:
String updateHistoryJSON
(...)
static mapping = {
updateHistoryJSON type: 'text', column: 'update_history'
}
在 MySQL 中,这基本上映射到一个 TEXT 列,其目的是存储 JSON 内容。
因此,在 DB 和 ElasticSearch 索引中,我都有 2 个实例: - 实例 1 有 updateHistoryJSON = '{"zip":null,"street":null,"name":null,"categories":[],"city":null}' - 实例 2 具有 updateHistoryJSON = '{}'
现在,我需要一个只返回实例 2 的 ElasticSearch 查询。
我一直在使用 Groovy DSL 进行这样的闭包:
{
bool {
must_not = term(updateHistoryJSON: "{}")
minimum_should_match = 1
}
}
而 ElasticSearch 似乎忽略了它,它不断返回两个实例。
另一方面,如果我使用像“missing”:{“field”:“updateHistoryJSON”}这样的过滤器,它不会返回任何文档。 "exists" 也是如此:{"field":"updateHistoryJSON"}。
知道我在这里做错了什么吗?
【问题讨论】:
标签: grails elasticsearch