Skip to content

Instantly share code, notes, and snippets.

@mbarretta
Last active April 2, 2018 14:39
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 mbarretta/0feae006cab50c8011db75cf93c274bb to your computer and use it in GitHub Desktop.
Save mbarretta/0feae006cab50c8011db75cf93c274bb to your computer and use it in GitHub Desktop.
attribute length via ingest node
# Create our mapping with a single attribute array: projects
PUT abac-ingest-node-test
{
"mappings": {
"doc": {
"properties": {
"projects": {
"type": "keyword"
}
}
}
}
}
# Define pipeline to create a new projects_count field
PUT _ingest/pipeline/abac-test
{
"description": "abac test",
"processors": [
{
"script": {
"inline": "ctx.projects_count = ctx.projects.length"
}
}
]
}
# Load docs
POST abac-ingest-node-test/doc?pipeline=abac-test
{
"projects": ["project-a","project-b"]
}
POST abac-ingest-node-test/doc?pipeline=abac-test
{
"projects": ["project-a","project-b", "project-c"]
}
# Notice the correctly formed project_count field
GET abac-ingest-node-test/_search
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment