Elastisearch多匹配搜索无法正常运行

时间:2018-10-12 10:39:45

标签: elasticsearch

我在elasticsearch中有一个用户,用户的全名是Mike John Khosa,用户名是mikekhosa。因此,当我搜索用户khosa时,该用户应进入搜索结果,但在当前情况下当前未搜索到该用户。下面是我的工作代码

{
  "from": 0,
  "size": 40,
  "sort": [
    {
      "username.raw": {
        "order": "desc"
      }
    }
  ],
  "_source": [
    "id",
    "uid",
    "username",
    "full_name",
    "picture",
    "bucket"
  ],
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "type": "user"
          }
        },
        {
          "term": {
            "db_id": 27428
          }
        },
        {
          "multi_match": {
              "query": "khosa",
              "type": "cross_fields",
              "fields": [
                "username.raw",
                "username",
                "full_name.raw",
                "full_name"
              ]
            }
        }
      ],
      "must_not": {
        "terms": {
          "id": [
            "u-2",
            "u-19712"
          ]
        }
      }
    }
  }
}

我在Google上搜索了5个多小时,但未能实施好的解决方案。我不知道我在哪里做错

0 个答案:

没有答案