如何在 match_all elasticsearch 中提升字段

How to boost the field in match_all elasticsearch

下面是查询

GET /_search

{"from" : 0, "size" : 100,"query": {"match_all": {}}})

如何实现"fields": [ "professor.name^16", "professor.email^8"]

您可以使用基于匹配查询的 multi_match query 构建以允许 multi-field 查询:

搜索查询:

{
  "query": {
    "multi_match" : {
      "query" : "thomas",
      "fields" : [ "professor.name^16", "professor.email^8"]
    }
  }
}

搜索结果:

"hits": [
      {
        "_index": "stof_64275333",
        "_type": "_doc",
        "_id": "1",
        "_score": 15.693266,
        "_source": {
          "id": "Accounting 101",
          "room": "E3",
          "professor": {
            "name": "Thomas Baszo",
            "email": "baszot@onuni.com"
          },
          "students_enrolled": 27,
          "course_description": " financial statements"
        }
      },
      {
        "_index": "stof_64275333",
        "_type": "_doc",
        "_id": "3",
        "_score": 7.846633,
        "_source": {
          "name": "Accounting 101",
          "room": "E3",
          "professor": {
            "name": "Sachin Baszo",
            "email": "Thomas@onuni.com"
          },
          "students_enrolled": 27,
          "course_description": "Nothing"
        }
      }
    ]