elasticsearch - Elasticsearch - 只要我使用正确的开始时间,在我的初始查询中使用“searchafter”有什么问题吗?
问题描述
根据文档,对弹性进行初始查询,从中检索排序时间戳。然后我使用 'searchafter' 进行后续查询,每次更改排序时间戳以检索我需要的记录。
例如:
`{"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"must":[{"range":{"Timestamp":{"gte":${stUnix},"format": "epoch_millis"}}},{"range":{"Timestamp":{"lte":${endUnix},"format": "epoch_millis"}}}]}}]}}]}},"sort":{"Timestamp": {"order":"asc"}},"size":${dateRadio}, "script_fields" : {
"test1" : {
"script" : {
"lang": "painless",
"source": "doc['InitiatorBytes'].value + doc['ResponderBytes'].value"
}
}
},"_source":{"includes":["*"],"excludes":[]},"from":0}\n`;
运行此初始查询后,我使用响应中的排序时间戳来运行后续查询。
`{"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"must":[{"range":{"Timestamp":{"gte":${stUnix},"format": "epoch_millis"}}},{"range":{"Timestamp":{"lte":${endUnix},"format": "epoch_millis"}}}]}}]}}]}},"search_after":[${sortUnix}],"sort":{"Timestamp": {"order":"asc"}},"size":${dateRadio},"_source":{"includes":["*"],"excludes":[]},"from":0}\n`
在上面,我将 sortunix 变量设置为我从初始查询中检索到的排序时间戳。对于所有后续查询,我只使用上面的内容并插入排序时间戳响应。在这两个查询中,我在 gte:'stUnix' 中设置了相同的初始开始时间
我的问题是是否可以取消第一个查询并将初始 searchafter 'sortunix' 变量设置为等于 'stunix' 变量。
我试过这样做,它似乎工作正常,但我不确定它是否会影响数据的完整性。
解决方案
推荐阅读
- delphi - 使用 TMS 将 SVG 导出为 PDF?
- python - 更改熊猫数据框中的第一列
- reactjs - React - 基于数组的渲染组件 - 如何在 mongoDB 中包含来自父级的函数?
- go - 测试 row.scan 时如何模拟 sqlmock 错误
- java - Java继承转换运行时错误与编译器错误
- javascript - ParticleJS 与液体
- angular - 当验证中使用的 @Input 修饰变量发生更改时,为什么 *ngIf 不更新?
- java - 线程的意外行为
- flutter - 通过 dart 上的循环生成列表
- c - 为什么将“超出范围的整数转换为整数”会导致 IB,但将“超出范围的浮点数转换为整数”会导致 UB?