gpt4 book ai didi

elasticsearch - 弹性如何在给定另一个字段值的情况下定义映射

转载 作者:行者123 更新时间:2023-12-03 00:48:48 25 4
gpt4 key购买 nike

这是我的数据:

 {
"firstname" : "blablabla",
...
"otherDatas" : [
{
"reference" : "40xxx1372",
"universe" : "marketing",
"dataType" : "id"
},
{
"reference" : "roleA",
"universe" : "finance",
"dataType" : "role"
}
],
}

我需要做的是仅在我的otherDatas的数据类型为“role”时,为otherDatas特殊情况创建一个映射,例如拥有otherDatas.role.reference:关键字。

因此,我可以搜索组织中具有给定角色的所有用户

有办法实现吗?

最佳答案

同样重要的是在设计映射之前了解values中的类型key。请研究textkeyword类型之间的区别。我假设所有这些字段都是keyword,表示一个单词,不需要对这些值进行任何分析。

谈到您的映射,我相信nested对象可能使您感到困惑。这是您的处理方法(如果有任何具体问题,请告诉我)

PUT so_test14
{
"mappings": {
"_doc":{
"properties":{
"firstname": {"type":"keyword"},

"otherDatas": {
"type": "nested",
"properties": {
"reference": {"type": "keyword"},
"universe": {"type": "keyword"},
"dataType": {"type": "keyword"}
}
}
}
}
}
}

关于elasticsearch - 弹性如何在给定另一个字段值的情况下定义映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56890993/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com