Skip to content

Instantly share code, notes, and snippets.

@derickson
Created October 11, 2017 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derickson/300e1d6d026500b3ea59d015de2c5ec2 to your computer and use it in GitHub Desktop.
Save derickson/300e1d6d026500b3ea59d015de2c5ec2 to your computer and use it in GitHub Desktop.
PUT my_index
{
"mappings": {
"properties": {
"securityTags": {
"type": "keyword",
"fields": {
"length": {
"type": "token_count",
"analyzer": "standard"
}
}
}
}
}
}
POST /my_index/1
{
"sensitiveData": "Dave Erickson lives in Wahshington DC"
"securityTags": ["DaveLocation", "DaveFullName"]
}
POST /_xpack/security/role/dave_security_role
{
cluster: [],
"indices": [
{
"names": ["my_index"],
"privileges": ["read"],
"query": {
"terms_set": {
"securityTags": {
terms: ["DaveFullName", "DaveLocation", "DaveCatNames"],
minimum_should_match_field: "securityTags.length"
}
}
}
}
]
}
@mbarretta
Copy link

mbarretta commented Mar 27, 2018

@derickson The problem with the token_count is that it's counting tokens, not counting the length of the securityTags list. See this full example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment