问题描述
我的数据如下:
({
"fullName": "Name","Interest": [
{
"standard": "standard_name","startDate": "Date1","endDate": "Date2"
},{
"standard": "standard_name2","endDate": "Date2"
}
]
},{
"fullName": "Name2","Interest": [
{
"standard": "standard_name_P2","startDate": "Date1_2","endDate": "Date2_2"
},{
"standard": "standard_name2_V2_2","endDate": "Date2_2"
}
]
})
映射:
{
"mappings": {
"properties": {
"fullName": {
"type": "text","fields": {
"keyword": {
"type": "keyword","ignore_above": 256
}
}
},"interest": {
"type": "nested","properties": {
"standard": {
"type": "keyword"
},"startDate": {
"type": "date","format": "yyyy||MM-yyyy||yyyy-MM-dd"
},"endDate": {
"type": "date","format": "yyyy||MM-yyyy||yyyy-MM-dd"
}
}
}
}
}
}
我的目标是创建包含 endDate
和 standard
匹配 AND 其 startDate
和 standard
匹配的名称的存储桶。
最好是,startDate
的 standard
应该在分桶 endDate
的 standard
之后
date_hist_end_date = {"same_time_leave":A('date_histogram',field="interest.endDate",calendar_interval=interval_txt,format=interval_fmt,order="desc",offset="-365d")}
same_interest = {"same_standard": A('terms',field="interest.standard",order="desc")}
source_aggs_end = [date_hist_end_date,same_interest]
search_object.aggs.bucket('all_interest',"nested",path="interest") \
.bucket("comp","composite",sources=source_aggs_end,size=500) \
.bucket('same_year_interest',"date_histogram",field="interest.startDate",interval=interval_txt,keyed=True )\
从这里开始,我进行了反向嵌套以获取存储桶中的 fullName
。
这会向我显示在同一日期以相同兴趣开始和结束的那些项目,但不会向我显示它们是否以新兴趣开始。
有没有办法利用复合材料来完成这项任务,或者完全采用其他方式?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)