我已经阅读了很多关于 Elasticsearch 中的映射的内容,这是我发现的一些有趣的东西
Field names with the same name across types are highly recommended to have
the same type and same mapping characteristics (analysis settings for
example). There is an effort to allow to explicitly "choose" which field to
use by using type prefix (my_type.my_field), but it’s not complete, and there
are places where it will never work (like faceting on the field).
我从这里的文档中找到了上面的引用
现在我的用例就是这样。这是一个例子。假设some field
在tenant1 中必须具有以下映射(对于给定的实体用户):
{
"tenantId1_user": {
"properties": {
"someField": {
"type": "string",
"index":"analyzed"
}
}
}
}
现在,对于不同租户中的相同字段(对于相同的实体类型,比如说用户),类型必须更改如下:
{
"tenantId2_user": {
"properties": {
"someField": {
"type": "int",
"index":"analyzed"
}
}
}
}
现在从我从上面的引用中了解到,这意味着即使我可以提供这种映射,技术上也不推荐,因为 Lucene 以同样的方式处理它们。
我的问题是:
1)如何处理我的用例?我是否应该在不同的索引中分离出每个租户,这样我就不必担心这个映射?
2)还有其他解决方法吗?考虑到如果我有太多租户,这意味着我将拥有太多索引这一事实?
3)这个用例的推荐方法是什么?
所有帮助表示赞赏!