elasticsearch Elasticsearch错误-没有为[query]注册查询,elasticsearch,elasticsearch" /> elasticsearch Elasticsearch错误-没有为[query]注册查询,elasticsearch,elasticsearch" />

elasticsearch Elasticsearch错误-没有为[query]注册查询

elasticsearch Elasticsearch错误-没有为[query]注册查询,elasticsearch,elasticsearch,我希望有人能帮助我,当我试图查询Elasticsearch时,我遇到了以下错误 No query registered for [query] 我使用的查询是: { "query": { "bool": { "must": { "terms": { "facet_1": [ "1",

我希望有人能帮助我,当我试图查询Elasticsearch时,我遇到了以下错误

No query registered for [query]
我使用的查询是:

{
    "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"
    }
}

我已经尝试了大量的变化,但似乎无法达到这一点。我真的非常感谢您的帮助。

我已经想好了,要在
必须
不得
应该
中添加额外内容,它们必须位于外部数组中,如:

"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"
    }
}

无论如何,谢谢你的关注。

我已经弄明白了,要向
必须
必须不
应该
添加额外内容,它们必须位于外部数组中,如:

"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"
    }
}
无论如何,谢谢你的关注