且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Elasticsearch:期望的字段名称,但获得了START_OBJECT

更新时间:2021-08-16 16:30:20

您的field_value_factor函数放错了位置.它应嵌套在functions属性.尝试使用此查询

Your field_value_factor function is misplaced. it should be nested within the functions property. Try this query instead

{
  "query": {
    "function_score": {
      "functions": [
        {
          "field_value_factor": {
            "field": "thread_view"
          }
        }
      ],
      "query": {
        "bool": {
          "should": [
            {
              "match": {
                "thread_name": "parenting"
              }
            },
            {
              "nested": {
                "path": "messages",
                "query": {
                  "bool": {
                    "should": [
                      {
                        "match": {
                          "messages.message_text": "parenting"
                        }
                      }
                    ]
                  }
                },
                "inner_hits": {}
              }
            }
          ]
        }
      }
    }
  }
}