Skip to content

Instantly share code, notes, and snippets.

@djptek
Created February 12, 2019 10:36
Show Gist options
  • Select an option

  • Save djptek/8c0f34c5ccc442be824920c168e93181 to your computer and use it in GitHub Desktop.

Select an option

Save djptek/8c0f34c5ccc442be824920c168e93181 to your computer and use it in GitHub Desktop.
Map an integer field as keyword multi-field
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