elasticsearch解释查询以了解正在访问哪些字段

lf5gs5x2  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(0)|浏览(154)

我正在为我们的数据科学家实现一个ElasticSearch权限系统(通过代理微服务访问),以防止某些用户查询特定字段。
我一直在查看es文档,以找出是否有任何开源函数返回通过查询访问的所有字段,但没有运气。只有xpack提供了一个解决方案,但据我所知,xpack不是开源的,而且它对我们来说非常昂贵。https://www.elastic.co/guide/en/elasticsearch/reference/current/field-level-security.html
例如

{
  "from" : 1,
  "size" : 2,
  "query" : {
    "bool" : {
      "filter" : [
        {
          "bool" : {
            "must" : [
              {
                "nested" : {
                  "query" : {
                    "bool" : {
                      "must" : [
                        {
                          "term" : {
                            "nestedField.nestedAbc.fieldNotSupposedToAccess" : {
                              "value" : 0.102908,
                              "boost" : 1.0
                            }
                          }
                        }
                      ],
                      "adjust_pure_negative" : true,
                      "boost" : 1.0
                    }
                  },
                  "path" : "nestedField.nestedAbc",
                  "ignore_unmapped" : false,
                  "score_mode" : "none",
                  "boost" : 1.0
                }
              }
            ],
            "adjust_pure_negative" : true,
            "boost" : 1.0
          }
        }
      ],
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  },
  "_source" : {
    "includes" : [
      "_doc"
    ],
    "excludes" : [ ]
  },
   "function_score": {
      "script_score": {
        "script": {
          "lang": "painless",
          "source": """
            int total = 0;
            for (int i = 0; i < doc['goals'].length; ++i) {
              total += doc['goals'][i];
            }
            return total;
          """
        }
      }
    }
}

我想我会得到一个所有字段的列表,比如:

["nestedField.nestedAbc.fieldNotSupposedToAccess","_doc","goals"]

除了从头开始创建一个复杂的解析器之外,还有别的想法吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题