Elasticsearch-dsl 多复合聚合即将开始

问题描述

我的数据如下:

({
  "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"
                    }
                }
            }
        }
    }
}

我的目标是创建包含 endDatestandard 匹配 ANDstartDatestandard 匹配的名称的存储桶。

最好是,startDatestandard 应该在分桶 endDatestandard 之后

我尝试使用复合查询执行此操作,但无法链接这 2 个查询

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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...