我正在尝试在Elasticsearch中构建一个有点复杂的查询。该查询是使用ongr / elasticsearch-dsl包在PHP中构建的。这是查询的样子:
Array
(
[query] => Array
(
[function_score] => Array
(
[query] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[query_string] => Array
(
[query] => name_suggest:car
[fuzziness] => 2
[analyzer] => autocomplete_analyzer
)
)
)
[should] => Array
(
[0] => Array
(
[prefix] => Array
(
[name] => Array
(
[value] => term
)
)
)
)
)
)
[functions] => Array
(
[0] => Array
(
[filter] => Array
(
[term] => Array
(
[is_category] => 1
)
[weight] => 5
)
)
)
[score_mode] => sum
[boost_mode] => sum
)
)
)
这是查询的json版本:
{
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "name_suggest:hrad",
"fuzziness": 2,
"analyzer": "autocomplete_analyzer"
}
}
],
"should": [
{
"prefix": {
"name": {
"value": "term"
}
}
}
]
}
},
"functions": [
{
"filter": {
"term": {
"is_category": true
},
"weight": 5
}
}
],
"score_mode": "sum",
"boost_mode": "sum"
}
},
"min_score": 0.5
}
我收到以下错误:
query_parsing_exception: [_na] query malformed, must start with start_object
我正在努力解决这个错误。有人可以帮我吗?我正在运行Elasticsearch 5.