我希望有人能提供帮助,当我尝试查询Elasticsearch时遇到以下错误
No query registered for [query]
Run Code Online (Sandbox Code Playgroud)
我正在使用的查询是:
{
"query": {
"bool": {
"must": {
"terms": {
"facet_1": [
"1",
"2"
]
},
"function_score": {
"query": {
"multi_match": {
"query": "fat dog food",
"fields": [
"family_name^20",
"parent_categories^2",
"description^0.2",
"product_suffixes^8",
"facet_values^10"
],
"operator": "and",
"type": "best_fields",
"tie_breaker": 0.3
}
},
"functions": [
{
"script_score": {
"script": "_score + ((_score * 0.3) + (log(1 + doc[\"popularity_score\"].value) * 2))"
}
}
],
"score_mode": "sum"
}
},
"must_not": {
"terms": {
"facet_1": [
"8"
]
}
}
}
},
"fields": [
"family_id",
"family_name",
"parent_categories",
"description",
"image",
"url",
"price_from",
"price_to",
"price_from_id",
"price_to_id",
"products_ids",
"popularity_score"
],
"from": 0,
"size": 48,
"sort": {
"_score": "desc"
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多变化,但是似乎还不能达到目标。我真的很感谢您的帮助。
我已经想通了,要额外添加到must,must_not或者should,他们必须在外部阵列,如:
"query": {
"bool": {
"must": [
{
"terms": {
"facet_1": [
"1",
"2"
]
}
},
{
"function_score": {
"query": {
"multi_match": {
"query": "fat food",
"fields": [
"family_name^20",
"parent_categories^2",
"description^0.2",
"product_suffixes^8",
"facet_values^10"
],
"operator": "and",
"type": "best_fields",
"tie_breaker": 0.3
}
},
"functions": [
{
"script_score": {
"script": "_score + ((_score * 0.3) + (log(1 + doc[\"popularity_score\"].value) * 2))"
}
}
],
"score_mode": "sum"
}
}
]
}
},
"fields": [
"family_id",
"family_name",
"parent_categories",
"description",
"image",
"url",
"price_from",
"price_to",
"price_from_id",
"price_to_id",
"products_ids",
"popularity_score"
],
"from": 0,
"size": 48,
"sort": {
"_score": "desc"
}
}
Run Code Online (Sandbox Code Playgroud)
仍然感谢您的关注。
| 归档时间: |
|
| 查看次数: |
4124 次 |
| 最近记录: |