和操作人员(过滤器) [英] And operator mongoosastic (filter)
本文介绍了和操作人员(过滤器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在我的查询中添加过滤器,以获取例如只有角色管理员
的用户?
How can I add filter to my query to get for example just users where role admin
?
这里是我的查询:
userModel.search({
"multi_match": {
"fields": ["firstName", 'lastName', 'specialities', 'profession', 'country', 'state', 'city'],
"query": req.query.q,
"fuzziness": "AUTO"
}
},
{
from: (pageNum - 1) * perPage,
size: perPage
},
function (err, results) {
...
我需要做某事喜欢这样只是与mognoosastic:
ElasticSearch - 多匹配过滤器 - 不返回结果
I need to do something like this just with mognoosastic: ElasticSearch - multi-match with filter - returns no result
推荐答案
尝试下面的查询格式
"query": {
"bool": {
"must": {
"multi_match": {
"query": "values",
"fields": [
"filed_one","field_two"
]
}
},
"filter": {
"range": {
"field_name": {
"gte": 1467311400,
"lte": 1468866599
}
}
}
}
}
让我知道这种格式是否有帮助
Let me know if this format help or not
这篇关于和操作人员(过滤器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文