我有一个在本地运行的 flex 搜索引擎,其中的索引包含来自多个客户的数据。当客户进行查询时,有一种方法可以在过滤条件中动态添加客户ID,以便客户无法访问其他客户的记录。
最佳答案
是的,您可以使用filtered aliases来实现。因此,您需要为每个客户创建一个别名,如下所示:
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "customer_index",
"alias" : "customer_1234",
"filter" : { "term" : { "customer_id" : "1234" } }
}
}
]
}
然后,您的客户可以简单地查询别名
customer_1234
,而只有他的数据会返回。