我正在尝试在父级和嵌套对象级别对基于文本的字段进行模糊搜索来聚合嵌套字段。我能够聚合父级属性,但是对于基于文本字段类型的搜索的嵌套字段的聚合时间很困难。
假设我的输入是:
[
{
"folder_name": "action Hero 2021", // Text
"folder_tag": "ACTION", // Keyword
"files": [
{
"file_name": "movie1.txt", // Keyword
"file_text": "this is a action hero movie subtitles for a movie 1 released in the year 2021", // Text
"quality": "High" // Keyword
},
{
"file_name": "movie2.txt",
"file_text": "this movie subtitles for a movie 2 released in the year 2021",
"quality": "Medium"
},
{
"file_name": "movie3.txt",
"file_text": "this is a action hero movie subtitles for a movie 3 released in the year 2021",
"quality": "Low"
}
]
},
{
"folder_name": "action Hero 2022",
"folder_tag": "ACTION",
"files": [
{
"file_name": "movie4.txt",
"file_text": "this is a action hero movie subtitles for a movie 4 released in the year 2021",
"quality": "High"
},
{
"file_name": "movie5.txt",
"file_text": "this is a subtitles for a movie 5 released in the year 2021",
"quality": "Medium"
},
{
"file_name": "movie6.txt",
"file_text": "this is a action hero movie subtitles for a movie 6 released in the year 2021",
"quality": "Low"
}
]
}
]
输入搜索文本 - “动作英雄”:
fields - folder_name, [matches both "action Hero 2021" and "action Hero 2022"]
files.file_text [matches text on movie1.txt, movie3.txt,movie4.txt and movie6.txt ]
我想汇总以下字段:
folder_tag (Parent Level)
quality (child level)
预期的综合结果
folder_tags_aggr_results [聚合父字段 folder_name]
"buckets": [
{
"key": "ACTION",
"doc_count": 2
}
]
files_quality_aggr_results [聚合嵌套对象中的质量字段]
"buckets": [
{
"key": "High",
"doc_count": 2
},
{
"key": "Low",
"doc_count": 2
}
]