【发布时间】:2025-12-22 07:40:11
【问题描述】:
我有一个用例,其中有一个基本实体,它根据一些参数被覆盖。在不存在覆盖的情况下,我想回退到最匹配的实体。
例如
{
"id": "uuid1",
"key": "welcome",
"meta": {
"abParam": "v1"
},
"Entity": {
"Text": "hello"
}
}
{
"id": "uuid2",
"key": "welcome",
"meta": {
"abParam": "v2"
},
"Entity": {
"Text": "hi"
}
}
{
"id": "uuid3",
"key": "welcome",
"meta": {
"abParam": "v2",
"userType": "new"
},
"Entity": {
"Text": "hi"
}
}
{
"id": "uuid4",
"key": "welcome",
"meta": {
},
"Entity": {
"Text": "hi"
}
}
这些是我想要的查询,以及我期待的结果
| Query | Response | Comment |
|---|---|---|
| key=welcome, meta.abParam:v2 | uuid2 | match the most matching document |
| key=welcome, meta.abParam:v3 | uuid4 | fallback to default, if does not match |
| key=welcome, meta.abParam:v2, meta.userType: new | uuid3 | since there are 2 filter matches |
我知道弹性搜索可以通过权重函数支持这一点,但是
-
是否可以在 Mongo、Mysql、Hbase、Couchbase 等其他数据库中进行建模? (如果数据库不支持这个查询,我将不得不在应用层构建优先级逻辑,这更难扩展,考虑到我必须将大量数据从数据库传输到应用层,然后应用过滤器。)
-
还有哪些其他选项可以支持此用例
【问题讨论】: