一尘不染

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

elasticsearch

我一直在尝试运行以下查询,但是每次运行它时,都会收到以下错误:

nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"field_value_factor\"]; }]","status":400

这是查询:

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

阅读 482

收藏
2020-06-22

共1个答案

一尘不染

您的field_value_factor功能放错了位置。它应该嵌套在functions属性中。试试这个查询

{
  "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": {}
              }
            }
          ]
        }
      }
    }
  }
}
2020-06-22