我的数据看起来像这样:
[{
"id":"1",
"name": "Champ",
"lastName": "Camp",
"address": "1922 Breaking Change",
"postalCode": "34802",
"businessLine": "line1"
}, {
"id":"2",
"name": "Kamp",
"lastName": "Mamp",
"address": "1922 Breaking Change 1",
"postalCode": "138283",
"businessLine": "line2"
}, {
"id":"3",
"name": "Jamp",
"lastName": "Tamp",
"address": "1922 Breaking Change 2",
"postalCode": "18941",
"businessLine": "line1"
}, {
"id":"4",
"name": "Kamp",
"lastName": "Mamp",
"address": "1922 Breaking Change 1",
"postalCode": "138283",
"businessLine": "line2"
}, {
"id":"5",
"name": "Gamp",
"lastName": "Damp",
"address": "1922 Breaking Change 12",
"postalCode": "121333",
"businessLine": "line1"
}]
问题是我必须确保与businessLine相关的可搜索字段的安全性。某些字段受businessLine级别安全性保护。这意味着如果您属于businessLine,则name,postalCode,address等字段仅可搜索。
场景: line1可以访问字段“name”,而line2可以访问字段“postalCode”。
因此,对于可以访问businessLines,line1和line2的用户,只能在具有ID 1,2和5的文档中搜索字段“name”。 但邮政编码将无法在这些文件中搜索到。 现场邮政编码只能在ID为2和4的文档中进行搜索。
我尝试了一些有效的方法:
{
"query": {
"query_string" : {
"default_field" : "content",
"query" : "("name" :"amp" AND (businessline : line1 OR line3)) ("postalCode" :"amp" AND (businessline : line2 OR line3))"
}
}
}
这会产生预期的结果,但是有更好的方法可以解决这个问题吗?