elasticsearch - 我可以在嵌套字段中为弹性搜索中的不同块使用 spannear 吗?
问题描述
该文件是这样的:
doc = {
"id": 1,
"content": [
{
"txt": I,
"time": 0,
},
{
"txt": have bla bla,
"time": 1,
},
{
"txt": bla bla book,
"time": 2,
},
{
"txt": do not match this block,
"time": 3,
},
]
}
搜索查询是这样的:
"span_near": {
"clauses": [
{"span_term": {"content.txt": "I"}},
{"span_term": {"content.txt": "book"}},
],
"slop": 5,
"in_order": False,
}
我想返回 "content.time": [0,1,2]
现在,我知道通过使用嵌套字段,可以检索“content.time”,但似乎“content.txt”在每个块之间是分开的。我想像扁平结构一样搜索整个“content.txt”,但仍然可以返回匹配的“content.time”。有谁知道如何实现这一目标?谢谢!
解决方案
推荐阅读
- arrays - 根据 Google 表格中的下拉列表填充单元格
- c# - Rider 样式不适用于具有 6000 多行的 C# 文件
- java - 尝试从数据库中检索数据时出现 NoInitialContextException。Heroku Java Web 应用程序
- xml - OptaPlanner:pillarSwapMoveSelector 多个 variableNameInclude 元素
- python-3.x - Python - 将字符串作为套接字编程中的参数传递给客户端
- python - 如何在 asyncio 和 PyQt5 事件循环中使用回调和期货?
- c++ - 包含在 main.cpp 之外的文件中时未找到 SDL2
- python - 不支持在图形模式下调用“myModel.predict”
- css - 如何在 React Navigation 6 的标题中输入全角文本?
- python - 如何在不丢失几何细节的情况下粗化 Python 中过细的网格?