Grails 中的多个 ElasticSearch 过滤器
Multiple ElasticSearch filters in Grails
我在 Grails(插件 elasticsearch:0.0.3.8)中有以下查询,效果很好:
class MyDomain {
User user
String text
Boolean deleted
Boolean disabled
static searchable = { user component:true }
}
class User {
String name
static searchable = { root false }
}
MyDomain.search(searchType: 'dfs_query_and_fetch') {
query_string(query: params.query, fields:['text'])
} {
nested {
path = "user"
query {
bool {
must { match("user.name": params.name) }
}
}
}
}
但现在我想添加一些额外的过滤器:
匹配("deleted":真)
匹配("disabled":真)
有人可以向我解释如何实现这一目标吗?谢谢
我终于明白了。非常感谢 cfrick 的帮助。
MyDomain.search(searchType: 'dfs_query_and_fetch') {
query_string(query: params.query, fields:['text'])
} {
bool {
must { term(disabled: true) }
must { term(deleted: true) }
must {
nested {
path = "user"
query {
bool {
must { match("user.name": params.name) }
}
}
}
}
}
}
我在 Grails(插件 elasticsearch:0.0.3.8)中有以下查询,效果很好:
class MyDomain {
User user
String text
Boolean deleted
Boolean disabled
static searchable = { user component:true }
}
class User {
String name
static searchable = { root false }
}
MyDomain.search(searchType: 'dfs_query_and_fetch') {
query_string(query: params.query, fields:['text'])
} {
nested {
path = "user"
query {
bool {
must { match("user.name": params.name) }
}
}
}
}
但现在我想添加一些额外的过滤器: 匹配("deleted":真) 匹配("disabled":真)
有人可以向我解释如何实现这一目标吗?谢谢
我终于明白了。非常感谢 cfrick 的帮助。
MyDomain.search(searchType: 'dfs_query_and_fetch') {
query_string(query: params.query, fields:['text'])
} {
bool {
must { term(disabled: true) }
must { term(deleted: true) }
must {
nested {
path = "user"
query {
bool {
must { match("user.name": params.name) }
}
}
}
}
}
}