Created
February 12, 2019 10:36
-
-
Save djptek/8c0f34c5ccc442be824920c168e93181 to your computer and use it in GitHub Desktop.
Map an integer field as keyword multi-field
This file contains hidden or 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
| DELETE my_index | |
| PUT my_index | |
| { | |
| "mappings": { | |
| "_doc": { | |
| "properties": { | |
| "ID": { | |
| "type": "long", | |
| "fields": { | |
| "keyword": { | |
| "type": "keyword" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| PUT my_index/_doc/1 | |
| { | |
| "ID": 1 | |
| } | |
| PUT my_index/_doc/2 | |
| { | |
| "ID": 2 | |
| } | |
| GET my_index/_search | |
| { | |
| "query": { | |
| "range": { | |
| "ID": { | |
| "gt": 1 | |
| } | |
| } | |
| } | |
| } | |
| # there is some coercion going on here... | |
| GET my_index/_search | |
| { | |
| "query": { | |
| "match": { | |
| "ID.keyword": 1 | |
| } | |
| } | |
| } | |
| GET my_index/_search | |
| { | |
| "aggs": { | |
| "my_ids": { | |
| "terms": { | |
| "field": "ID.keyword" | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment