elasticsearch - 多个和查询与子请求。弹性搜索
问题描述
当我有以下查询时,出现错误
{
"query": {
"bool": {
"must": [
{ "match": { "context.branch": "17270" }},
{ "match": { "context.version": "12.0.R2" }},
{ "match": { "run_uid": "AAA / SSS / AA-ContextMenu / 3507031CR3.exe"}},
{
"range": {
"epoch": {
"lte": 1510340778.78
}
}
}
]
}
}
}
映射:
{
"mappings": {
"_doc": {
"properties": {
"partition_id": {"type": "integer"},
"report_id": {"type": "integer"},
"title": {"type": "text"},
"epoch": {"type": "date",
"format": "epoch_millis"},
"context": {
"dynamic": True,
"properties": {}
},
"run_uid": {"type": "text"},
"run_id": {"type": "integer"},
"build_name": {"type": "text"},
"status_id": {"type": "integer"},
"rep_custom_id": {"type": "text"},
"created": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
}
}
}
}
}
你能告诉我为什么我仍然看到不同的run_uid吗?以下选项有效:
{ "match": { "context.branch": "17270" }},
{ "match": { "context.version": "12.0.R2" }}
但是 { "match": { "run_uid": "AAA / SSS / AA-ContextMenu / 3507031CR3.exe"} 不起作用。它返回我随机 run_uids 但正确的“context.branch”和“context.version”
例如,我有以下数据:
run_id context created
4 blabala132 2019-03-20 08:00:00.0000+0300
5 blabala132 2019-03-20 07:00:00.0000+0300
6 blabala132 2019-03-20 06:00:00.0000+0300
7 blabala132 2019-03-20 05:00:00.0000+0300
8 blabala132 2019-03-20 09:00:00.0000+0300
9 blabala133 2019-03-20 07:00:00.0000+0300
输入数据:run_id 4
结果如下:
5 blabala132 2019-03-20 07:00:00.0000+0300
6 blabala132 2019-03-20 06:00:00.0000+0300
7 blabala132 2019-03-20 05:00:00.0000+0300
每个数据小于2019-03-20 08:00:00.0000+0300(属于run_id 4),上下文相同。
8 blabala132 2019-03-20 09:00:00.0000+0300
上述字符串不在结果中,因为数据为 gt 2019-03-20 08:00:00.0000+0300(属于 run_id 4)
9 blabala133 2019-03-20 07:00:00.0000+0300
上述字符串不在结果中,因为上下文与 blabala132 不同(属于 run_id 4)
解决方案
首先,您的 JSON 结构不正确。之后,您的查询语法也不正确。它应该是这样的:
{
"query": {
"bool": {
"must": [
{
"term": {
"run_id": 5000
}
},
{
"term": {
"context": "{\"branch,keyword\": \"TRT-26878\",\"version\": \"12.0.R2\"}"
}
},
{
"range": {
"created.keyword": {
"lte": 1510047258.826,
"boost": 2
}
}
}
],
"minimum_should_match": 1,
"boost": 1
}
}
}
推荐阅读
- angular - StackBlitz 在使用 Angular Material 时显示错误
- swift - 后台计时器仅适用于模拟器?
- r - 如何创建一个新变量并为其分配一个与 R 中另一个变量相对应的值?
- javascript - Flask & AJAX - 捕获点击然后更新照片
- sdk - 使用汇总转换后看不到 jsdoc 方法建议
- javascript - 使用 ChartJs 超出了最大堆栈调用大小
- powershell - PowerShell 脚本和 Windows 性能监视器出现问题
- autodesk-forge - 对单个 OSS Bucket 中项目数量或大小的任何限制
- html - 无法使用 selenium 单击链接并出现错误
- function - 未来
' 不是类型 'Function?