gpt4 book ai didi

elasticsearch - Elasticsearch URI搜索过滤

转载 作者:行者123 更新时间:2023-12-03 01:26:34 25 4
gpt4 key购买 nike

我有一个带有以下映射的movies ES索引:

{
"doc": {
"properties": {
"director": {
"type": "text"
},
"genres": {
"type": "text",
"index": "false"
},
"title": {
"type": "text"
},
"year": {
"type": "long"
}
}
}
}

对于流派,我将提交一个字符串数组。现在,我想允许我的客户针对我的端点提交查询,在该端点中,我将 q请求参数代理到ES客户端。

但是我正在努力使用URI搜索过滤数据,方法与通过将查询作为有效载荷提交给我的索引一样,可以实现。例如:
GET movies/doc/_search
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"term": {
"genres": "War"
}
}
],

"must": [
{
"term": {
"genres": "Foo"
}
}
],

"must": [
{
"term": {
"genres": "Bar"
}
}
]
}
}
}
}
}

是否可以通过URI搜索来实现?如果是这样,怎么办?

最佳答案

从ES文档

You can use query parameters to define your search criteria directly in the request URI, rather than in the request body. Request URI searches do not support the full Elasticsearch Query DSL, but are handy for testing.



根据我们的讨论,建议您在收到客户端请求后在后端构建DSL查询。您需要公开一个API,该API可以将UI输入以结构化格式(JSON)发送到后端,这可以帮助您轻松构建DSL查询。

关于elasticsearch - Elasticsearch URI搜索过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58019242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com