Elasticsearch带有term和function_score的has_child查询,parsing_exception

时间:2017-09-04 12:20:33

标签: elasticsearch

向弹性搜索发送帖子请求以下是帖子数据

{
    "query": {
            "has_child" : {
                "type" : "sometype",
                "score_mode" : "sum",
                "query" : {
                    "term" : {
                        "somefield" : "somevalue"
                    },
                    "function_score" : {
                        "script_score": {"script": "1"}
                    }
                },
                "inner_hits": {}
            }
        }
      }
    }

获取格式错误的查询回复

{
"error": {
    "root_cause": [
        {
            "type": "parsing_exception",
            "reason": "[term] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
            "line": 10,
            "col": 17
        }
    ],
    "type": "parsing_exception",
    "reason": "[term] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
    "line": 10,
    "col": 17
},
"status": 400

}

阅读以下链接中的文档:https://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-dsl-has-child-query.html

Elasticsearch版本:5.4

1 个答案:

答案 0 :(得分:0)

您应该确保将(?i)term个查询包含在function_score个查询中,如下所示:

bool/filter