我的映射如下,
mapping = {
"mappings":{
"document": {
"properties": {
"title": {"type": "text"},
"users": {
"type": "nested",
"properties": {
"user_id": {"type": "integer"},
"name": {"type": "text"},
}
}
}
}
}
我可以很好地添加数据,但是当我使用搜索时
res = es.search(index="test", body={"query": {
"nested": {
"path": "users", "query": {
"match": {'users.user_id': 1}
}
}
}
}
它返回整个文档而不是特定行。
更多信息:
我正在为弹性搜索提供一个表格:
用户 ID | 姓名
1.............乔
2 ......玛丽
如果我在搜索中将 1 作为 user_id,我需要弹性搜索来返回 {user_id:1, name:Joe}