0
我在搜索嵌套字段時遇到問題。按嵌套字段搜索
例如我的文檔是:
{
"chat": [
{
"messages": [
{
"id": "61",
"text": "some text here"
},
{
"id": "62",
"text": "some62 text62 here62"
},
{
"id": "63",
"text": "some63 text63 here63"
},
{
"id": "64",
"text": "some64 text64 here64"
}
]
}
]
}
我通過messages.text搜索。如果我搜索
"text": "some"
{
"query" : {
"nested": {
"path": "messages",
"query": {
"bool": {
"must": [{
"match": {
"text": "some"
}
}]
}
}
}
}
}
我想輸出像
{
"chat": [
{
"messages": [
{
"id": "61",
"text": "some text here"
}
]
}
]
}
,而不是整個文件。我想我應該使用嵌套屬性,所以聊天消息被映射爲「嵌套」。 請大家幫幫我。