我正在尝试学习Elasticsearch,因此正试图找到一个适合我的查询需求的良好数据结构。
我的数据结构实际上看起来像这样:
{
"questions": [
{
"id": "n1-pain-score",
"name": "Pain score",
"answer": {
"value": 3,
"label": "Small pain"
}
},
{
"id": "n2-temperature",
"name": "Temperature",
"answer": {
"value": 37.5,
"label": "37.5°C"
}
}
]
}
对于给定的患者,存在多个问题和答案。有没有办法利用Elasticsearch过滤查询并说:I want to see the patients that have a pain score over 6
?
请注意,我只是在测试,我仍然可以修改数据结构以获取所需的内容:)。
可以使用过滤的查询。普通查询也可以:
GET {index}/{type}/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "Pain score"
}
},
{
"range": {
"answer.value": {
"gt":6
}
}
}
]
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句