elasticsearch - 如何在弹性搜索中查询特定的索引列表
问题描述
我正在创建基于日期的弹性索引,例如-logs-2017-06-10、logs-2018-07-10、logs-2019-06-11,日期后缀可以是任何有效日期。
如何将我的搜索查询限制为仅搜索特定日期索引。
例如,如果我想在 2018 年 6 月 9 日到 2018 年 6 月 11 日之间进行搜索,那么只有下面提到的索引应该针对我的查询进行搜索
logs-2018-06-09, logs-2018-06-10 and logs-2018-06-11
我尝试了通配符 * 但在这里没有帮助。
logs-2018-06-*
logs-2018-06-01 to logs-2018-06-30
将在不是我查询的索引中搜索。
我怎么能只限制它
logs-2018-06-09,logs-2018-06-10 and logs-2018-06-11
解决方案
GET /_search
{
"query": {
"indices" : {
"indices" : ["index1", "index2"],
"query" : { "term" : { "tag" : "wow" } },
"no_match_query" : { "term" : { "tag" : "kow" } }
}
}
}
来自:https ://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-dsl-indices-query.html
推荐阅读
- java - Android Studio 错误地将条件标记为始终为真
- python - Python Scrapy subscript-after 只返回第一个结果
- c++ - 仅在新值未更改时才进行存储的反向 CAS。有没有办法以原子方式实现这一目标?
- nginx - nginx中的动态proxy_pass,带有gitpod之类的端口
- regex - 匹配链接中的单词
- azure-logic-apps - 具有不同数据架构的 LogicApp
- python - KivyMD - MDDropdownMenu 图标未显示(Python 3.7 上的 Kivy)
- web - HTTPS 不适用于我的 www 子域 CNAME
- python-3.x - 基于参数的浮点格式?
- ggplot2 - 如何在ggplot2中的线段之间绘制角弧?