Last active
April 2, 2018 14:39
-
-
Save mbarretta/0feae006cab50c8011db75cf93c274bb to your computer and use it in GitHub Desktop.
attribute length via ingest node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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