gpt4 book ai didi

elasticsearch - N1QL和ElasticSearch加入

转载 作者:行者123 更新时间:2023-12-02 22:32:33 25 4
gpt4 key购买 nike

我的文件是:

Iwp::1::Porcentaje::Period::1
{
"id": null,
"period": 1,
"type": "IwpCumulative",
"category": "Porcentaje",
"sumEarn": 0,
"sumActual": 0.2248520710059172,
"sumForecast": 0,
"sumPlanned": 0,
"sumValue": 0,
"parent": "Iwp::1"
}

Iwp::1
{
"name": "Iwp 1",
"description": "Iwp 1 Description",
"manyPeriods": 50,
"type": "Iwp",
"countCC": 0,
"costCode": [
"CostCode::3",
"CostCode::4"
],
"iwpCumulatives": [
"Iwp::1::Porcentaje::Period::1",
.......
"Iwp::1::Porcentaje::Period::50",
"Iwp::1::Qty::Period::1",
........
"Iwp::1::Qty::Period::50",
]
}

我如何在ElasticSearch上执行此查询?

N1QL:
select 
t.category,
t.period,
sum(t.sumActual)
from
default as q
inner join default as p on keys q.parent
inner join default as t on keys p.iwpCumulatives
where
q.type = 'IwpCumulative'
and q.period = 50
and q.sumActual > 0
and q.category = 'Porcentaje'
group by t.category,t.period
order by t.period,t.category;

我在ElasticSearch上有以下查询:
{
"query":{
"filtered":{
"query":{
"bool":{
"must":[
{"term":{"period":"5"}},
{"term":{"type":"iwpcumulative"}},
{"range":{"sumActual":{"gt":"0"}}},
{"term":{"category":"porcentaje"}}
]
}
}
}
}
}

还有这个:
{
"size":0,
"aggs":{
"group_by_state":{
"terms":{
"field":"category"
},
"aggs":{
"costars":{
"terms":{
"field":"period"
},
"aggs":{
"Suma":{
"sum":{
"field":"earn"
}
}
}
}
}
}
}
}

现在,我需要使用第一个结果及其ID,以便在第二个查询中使用。

提前致谢。

最佳答案

因为只使用一张表会产生选择项(半联接),所以可以将siren-join插件用于elasticsearch:
看这个 :

SIREn Plugin to add relational join capabilities to Elasticsearch

关于elasticsearch - N1QL和ElasticSearch加入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31731412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com