基础数据:
{"index":{"_id":"dagrxx1"}}
{"dagrxx":{"grid":"1","xm":"张三","xb":"1","csrq":"1982-11-18"},"rhmjoin":{"name":"dagrxx"}}
{"index":{"_id":"dagrxx2"}}
{"dagrxx":{"grid":"2","xm":"李四","xb":"1","csrq":"1992-1-10"},"rhmjoin":{"name":"dagrxx"}}
{"index":{"_id":"gxysfjl1","_routing":"dagrxx1"}}
{"gxysfjl":{"sfid":"1","grid":"1","zz":"1","sg":"165","sfrq":"2018-7-1"},"rhmjoin":{"name":"gxysfjl","parent": "dagrxx1"}}
{"index":{"_id":"gxysfjl2","_routing":"dagrxx1"}}
{"gxysfjl":{"sfid":"2","grid":"1","zz":"2","sg":"155","sfrq":"2018-3-1"},"rhmjoin":{"name":"gxysfjl","parent": "dagrxx1"}}
{"index":{"_id":"tnbsfjl1","_routing":"dagrxx1"}}
{"tnbsfjl":{"sfid":"1","grid":"1","zz":"1","sg":"164","sfrq":"2018-7-1"},"rhmjoin":{"name":"tnbsfjl","parent": "dagrxx1"}}
{"index":{"_id":"gxysfjl3","_routing":"dagrxx2"}}
{"gxysfjl":{"sfid":"3","grid":"2","zz":"1","sg":"175","sfrq":"2018-7-1"},"rhmjoin":{"name":"gxysfjl","parent": "dagrxx2"}}
我想查出 gxysfjl.sfrq == tnbsfjl.sfrq && gxysfjl.zz == "1" && tnbsfjl.zz == "1" 的父记录
目前能写到的程度如下:
gxysfjl.sfrq == tnbsfjl.sfrq 这个条件不知道怎么加。
{"index":{"_id":"dagrxx1"}}
{"dagrxx":{"grid":"1","xm":"张三","xb":"1","csrq":"1982-11-18"},"rhmjoin":{"name":"dagrxx"}}
{"index":{"_id":"dagrxx2"}}
{"dagrxx":{"grid":"2","xm":"李四","xb":"1","csrq":"1992-1-10"},"rhmjoin":{"name":"dagrxx"}}
{"index":{"_id":"gxysfjl1","_routing":"dagrxx1"}}
{"gxysfjl":{"sfid":"1","grid":"1","zz":"1","sg":"165","sfrq":"2018-7-1"},"rhmjoin":{"name":"gxysfjl","parent": "dagrxx1"}}
{"index":{"_id":"gxysfjl2","_routing":"dagrxx1"}}
{"gxysfjl":{"sfid":"2","grid":"1","zz":"2","sg":"155","sfrq":"2018-3-1"},"rhmjoin":{"name":"gxysfjl","parent": "dagrxx1"}}
{"index":{"_id":"tnbsfjl1","_routing":"dagrxx1"}}
{"tnbsfjl":{"sfid":"1","grid":"1","zz":"1","sg":"164","sfrq":"2018-7-1"},"rhmjoin":{"name":"tnbsfjl","parent": "dagrxx1"}}
{"index":{"_id":"gxysfjl3","_routing":"dagrxx2"}}
{"gxysfjl":{"sfid":"3","grid":"2","zz":"1","sg":"175","sfrq":"2018-7-1"},"rhmjoin":{"name":"gxysfjl","parent": "dagrxx2"}}
我想查出 gxysfjl.sfrq == tnbsfjl.sfrq && gxysfjl.zz == "1" && tnbsfjl.zz == "1" 的父记录
目前能写到的程度如下:
{
"query": {
"bool": {
"filter": [{
"has_child": {
"type": "gxysfjl",
"query": {
"bool": {
"filter": [{
"term": {
"gxysfjl.zz": "1"
}
}]
}
}
}
}, {
"has_child": {
"type": "tnbsfjl",
"query": {
"bool": {
"filter": [{
"term": {
"tnbsfjl.zz": "1"
}
}]
}
}
}
}]
}
}
}
gxysfjl.sfrq == tnbsfjl.sfrq 这个条件不知道怎么加。
2 个回复
laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net
赞同来自:
myst
赞同来自:
这样可以查出,但是 这样就查不出,但不报错