Elasticsearch Version
7.17.4
Installed Plugins
analysis-ik,analysis-pinyin,analysis-stconvert
Java Version
1.8.0_331-b09
OS Version
MacBook-Pro.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
Problem Description
http://127.0.0.1:9200/cust_label_father_son_model
{
"mappings": {
"properties": {
"label": {
"properties": {
"id": {
"type": "long"
},
"age_numvalu":{
"type":"integer"
},
"cust_no": {
"type": "text",
"analyzer": "simple"
},
"name": {
"type": "text",
"analyzer": "simple"
},
"phone_number": {
"type": "text",
"analyzer": "simple"
},
"f1":{"type" : "text", "analyzer": "simple"},
"f2":{"type" : "text", "analyzer": "simple"},
"f3":{"type" : "keyword"},
"f3v":{"type" : "float"}
}
},
"custDeposit": {
"properties": {
"cust_no": {
"type": "text","analyzer": "simple"
},
"open_account_amont": {
"type": "float"
},
"open_account_date": {
"type": "date"
}
}
},
"custProduct": {
"properties": {
"cust_no": {
"type": "text","analyzer": "simple"
},
"product_encd": {
"type": "text","analyzer": "simple"
},
"prodct_nm": {
"type": "text","analyzer": "simple"
},
"total_amont": {
"type": "float"
},
"buy_amont": {
"type": "float"
}
}
},
"relation": {
"type": "join",
"relations": {
"label": ["custDeposit", "custProduct"]
}
}
}
}
}
This is the test data:
{"index":{"_id":"cust0","routing":"cust0"}}
{"cust_no":"1008263","age_numvalu":10,"name":"cust0","f3v":912.0,"id":"10000","f1":"1","f2":"g","f3":"l","relation":{"name":"label"}}
{"index":{"_index":"cust_label_father_son_model","routing":"cust0"}}
{"buy_amont":"2440","cust_no":"1008263","total_amont":"10364","relation":{"name":"custProduct","parent":"cust0"}}
{"index":{"_index":"cust_label_father_son_model","routing":"cust0"}}
{"buy_amont":"8318","cust_no":"1008263","total_amont":"8705","relation":{"name":"custProduct","parent":"cust0"}}
{"index":{"_index":"cust_label_father_son_model","routing":"cust0"}}
{"buy_amont":"6651","cust_no":"1008263","total_amont":"13456","relation":{"name":"custProduct","parent":"cust0"}}
{"index":{"_index":"cust_label_father_son_model","routing":"cust0"}}
{"buy_amont":"5036","cust_no":"1008263","total_amont":"96117","relation":{"name":"custProduct","parent":"cust0"}}
{"index":{"_index":"cust_label_father_son_model","routing":"cust0"}}
{"buy_amont":"6151","cust_no":"1008263","total_amont":"72155","relation":{"name":"custProduct","parent":"cust0"}}
{"index":{"_index":"cust_label_father_son_model","routing":"cust0"}}
{"open_account_amont":"490362","cust_no":"1008263","open_account_date":"2021-03-02","relation":{"name":"custDeposit","parent":"cust0"}}
I can't get the data by using the following methods:
http://127.0.0.1:9200/cust_label_father_son_model/_search
{
"query": {
"has_child": {
"type": "custProduct",
"query": {
"bool": {
"filter": [
{
"range": {
"buy_amont": {
"gte": 80
}
}
},
{
"match": {
"total_amont": 10364
}
}
]
}
}
}
}
}
But I can get the data in the following way, why
http://127.0.0.1:9200/cust_label_father_son_model/_search
{
"query": {
"has_child": {
"type": "custProduct",
"query": {
"bool": {
"filter": [
{
"range": {
"buy_amont": {
"gte": 100
}
}
},
{
"match": {
"total_amont": 10364
}
}
]
}
}
}
}
}
Why do you get no data over 80, but you can get data over 100