使用通配符搜索时,Elasticsearch SEARCH-API 会忽略一些现有索引
我想检索有关我的 elasticsearch 数据库中所有可用索引的信息。为此,我向“
请求正文与此问题无关。我只是简单地过滤一个字段的特定值。我希望 API 返回过去 30 天的所有索引。但是,我只收到一些可用的档案。缺少的日期包括:3月3日、2月11日至17日以及2月26日至27日。
但是当我通过“_CAT” API 检索所有可用索引时 “
我什至可以通过以下方式指定我在搜索 API 中查找的确切日期: “
那么,当我在搜索请求中使用通配符“*”时,elasticsearch 为何或如何不返回例如 2022 年 3 月 3 日的索引?
I want to retrieve information about all available indices in my elasticsearch db. For that I send a request to "<elasticsearch_endpoint>/logs-cfsyslog-*/_search/?format=json".
The body of the request is irrelevant for this problem. I'm simple filtering for a specifiy value for one field. I would expect that the api returns all indices of the last 30 days. However, I only receive some of the available archives. Some that are missing are: 3rd March, 11th-17th and 26th-27th February.
But when I retrieve all available indices with the "_CAT" API via
"<elasticsearch_endpoint>/_cat/indices/logs-cfsyslogs-*"
I can see ALL indices that I expect.
I can even specify the exact date that I'm looking for in the search API via:
"<elasticsearch_endpoint>/logs-cfsyslog-2022.03.03/_search/?format=json"
and the API will return the index that I specified.
So why or how does elasticsearch not return for example the index from 3rd March 2022 when I use the wildcard "*" in the search request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是由于以下原因之一造成的。
首先,大小的默认值为 10
考虑到您正在调用
"/logs-cfsyslog-*/_search/?format=json"
此 API 并且未传递size 参数,以便弹性搜索最多返回 10 个文档作为响应。尝试下面的 API 并检查您从哪个索引获得了多少结果。二、由于过滤
正如您在问题中提到的,您正在对特定值的一个字段应用过滤器,因此过滤条件可能与其他索引不匹配。
请检查您在响应中获得的
hits.total
值,并根据该值设置size
参数的值。请注意,elasticsearch 将返回最多 10,000
文档。it may be due to one of the below reson.
First, Default value of size is 10
Considering you are calling
"<elasticsearch_endpoint>/logs-cfsyslog-*/_search/?format=json"
this API and not passing size parameter so elastic search return max 10 documents in response. try below API and check how many result you are getting and from which index.Second, Due to filtering
As you mentioned in question, you are applying filter for one field on specific value so might be chances that filter condition is not matching with other indices.
Please check what value you are getting for
hits.total
in your response and based on that you can set value ofsize
parameter. Please not that elasticsearch will returnmax 10,000
documents.