【问题标题】:And operator mongoosastic (filter)和运算符 mongoosastic(过滤器)
【发布时间】:2017-01-09 08:22:19
【问题描述】:

如何向我的查询添加过滤器以获取例如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 - multi-match with filter - returns no result

【问题讨论】:

    标签: mongodb elasticsearch mongoosastic


    【解决方案1】:

    试试下面的查询格式

      "query": {
        "bool": {
          "must": { 
          "multi_match": {
          "query": "values",
          "fields": [
            "filed_one","field_two"
           ]
           }
          },
          "filter": {
            "range": {
              "field_name": {
                "gte": 1467311400,
                "lte": 1468866599
              }
            }
          }
        }
      }
    

    让我知道这种格式是否有帮助

    【讨论】:

    • 放在哪里?我还需要multi_match
    • 用 multi_match 编辑了我的答案,希望对你有帮助!!
    • 我需要过滤字符串字段roledoctor,可以过滤吗?
    • 添加值作为医生和 field_one 作为角色
    • 这样可以吗,请将答案标记为正确,以便其他人也可以参考
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    • 2018-03-19
    • 2016-01-12
    • 2019-06-22
    • 1970-01-01
    • 2017-07-15
    相关资源
    最近更新 更多