弹性搜索中 field_value_factor 的多个输入

multiple inputs to field_value_factor in elasticsearch

我正在尝试使用 field_value_factor 来制定 Elastic Search 查询以权衡文档中的某些字段。

{
  "query": {
    "match": {
      "local": true
    },
    "function_score": {
      "functions": [
        {
          "field_value_factor": {
            "field": "title",
            "factor": 1.2,
            "missing": 1
          }
        },
        {
          "gauss": {
            "location": {
              "origin": {
                "lat": 51.5,
                "lon": 0.12
              },
              "offset": "2 Miles",
              "scale": "3 Miles"
            }
          }
        },
        {
          "gauss": {
            "creation_time": {
              "decay": 0.8,
              "offset": "2d",
              "scale": "48d"
            }
          },
          "weight": 2
        }
      ]
    }
  }
}

任何输入如:

"field_value_factor": {
                             "field": [“title”,"description"],
                             "factor": [1.2,0.8],
                             "missing": [1,0]
                            }

不适用于这两个字段,查询检索与第一个相同的文档。

是否可以在 "field_value_vector" 中输入多个术语?

您可以使用多个 field_value_factor 函数,每个字段一个

{
  "query": {
    "match": {
      "local": true
    },
    "function_score": {
      "functions": [
        {
          "field_value_factor": {
            "field": "title",
            "factor": 1.2,
            "missing": 1
          }
        },
        {
          "field_value_factor": {
            "field": "description",
            "factor": 0.8,
            "missing": 0
          }
        },
        {
          "gauss": {
            "location": {
              "origin": {
                "lat": 51.5,
                "lon": 0.12
              },
              "offset": "2 Miles",
              "scale": "3 Miles"
            }
          }
        },
        {
          "gauss": {
            "creation_time": {
              "decay": 0.8,
              "offset": "2d",
              "scale": "48d"
            }
          },
          "weight": 2
        }
      ]
    }
  }
}