gpt4 book ai didi

elasticsearch - 在 Elasticsearch 查询中包含和排除索引

转载 作者:行者123 更新时间:2023-11-29 02:51:57 28 4
gpt4 key购买 nike

我有以下 Elasticsearch 查询。

GET /index1,index2/type1,type2/_search?q=programming

假设我想从这个搜索查询中排除 index2documentation states the following :

It also support wildcards, for example: test*, and the ability to "add" (+) and "remove" (-), for example: +test*,-test3.

据我所知,我应该能够做到以下几点。

GET /+index1,-index2/type1,type2/_search?q=programming

但是,我收到以下错误。

{
"error": {
"root_cause": [
{
"type": "index_not_found_exception",
"reason": "no such index",
"resource.type": "index_or_alias",
"resource.id": " index1",
"index": " index1"
}
],
"type": "index_not_found_exception",
"reason": "no such index",
"resource.type": "index_or_alias",
"resource.id": " index1",
"index": " index1"
},
"status": 404
}

如果我删除加号和减号,查询运行正常。如果我添加通配符,它​​似乎可以工作,例如以下查询。

GET /index1,-*index2/type1,type2/_search?q=programming

然而,这并不是我真正想要的。

当我按照文档说明使用加号和减号来包含或排除索引时,为什么我的查询不起作用?我是不是误会了什么?

我正在使用 Elasticsearch 2.1。

最佳答案

您需要对 + 符号进行编码,因为它在 URL 字符串中被视为 space。看到"resource.id": "index1",

中有 空格

这会起作用

GET /%2Bindex1,-index2/type1,type2/_search?q=programming

希望这对您有所帮助!

关于elasticsearch - 在 Elasticsearch 查询中包含和排除索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34578596/

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