Проблема с созданием ролей в open-distro для elasticsearch - PullRequest
0 голосов
/ 07 августа 2020

У меня 2 роли назначены одному пользователю. В первой роли я включаю имя поля для документов с _id 1 и 2

{
  "index_permissions": [
    {
      "index_patterns": [
        "test"
      ],
      "dls": "{\n    \"terms\": {\n      \"_id\": [ \"1\", \"2\"] \n    }\n}\n\n",
      "fls": [
        "name"
      ],
      "masked_fields": [],
      "allowed_actions": [
        "get",
        "crud"
      ]
    }
  ],
  "tenant_permissions": [],
  "cluster_permissions": [
    "*"
  ]
}

, а во второй роли я включаю поле job_description для документа с _id 3

{
  "index_permissions": [
    {
      "index_patterns": [
        "test"
      ],
      "dls": "{\n    \"terms\": {\n      \"_id\": [\"3\"] \n    }\n}\n",
      "fls": [
        "job_description"
      ],
      "masked_fields": [],
      "allowed_actions": []
    }
  ],
  "tenant_permissions": [],
  "cluster_permissions": []
}

когда я пытаюсь получить данные из индекса, он показывает мне job_description и name во всех документах,

{
  "took" : 237,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 2.0,
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 2.0,
        "_source" : {
          "name" : "John",
          "job_description" : "Systems administrator and Linux specialist"
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 2.0,
        "_source" : {
          "name" : "John",
          "job_description" : "Systems administrator and Linux specialist"
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 2.0,
        "_source" : {
          "name" : "John",
          "job_description" : "Systems administrator and Linux specialist"
        }
      }
    ]
  }
}

, но я хочу видеть единственное имя в двух первых записях и только job_description в 3 подобных документах

{
  "took" : 237,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 2.0,
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 2.0,
        "_source" : {
          "name" : "John",
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 2.0,
        "_source" : {
          "name" : "John",
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 2.0,
        "_source" : {
          "job_description" : "Systems administrator and Linux specialist"
        }
      }
    ]
  }
}

кто нибудь знает как это сделать?

...