Reputation: 330
I am trying to get fields with the name "IP" to be mapped as "ip" type with a .keyword field of type "keyword". The following mapping is not creating the .keyword field. How do I make elastic map this field?
"IP": {
"type": "ip",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
Upvotes: 0
Views: 952
Reputation: 330
TLDR: Need to flush the index after mappings are created.
The mappings are being created dynamically with dynamic mapping rules. When the first object comes through the new mapping is created. This information does not make it to Visualizations in Kibana immediately. You may have to flush the index after the mapping is created to make the new fields populate when building Visualizations.
Upvotes: 0
Reputation: 3680
I'm sharing an example for you to test it.
Please note that after you add the keyword
field you should run POST index_name/_update_by_query to update the existing data.
PUT test_ip
{
"mappings": {
"properties": {
"IP": {
"type": "ip"
},
"other_fields": {
"type": "keyword"
}
}
}
}
PUT test_ip/_mapping
{
"properties": {
"IP": {
"type": "ip",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
PUT test_ip
{
"mappings": {
"properties": {
"IP": {
"type": "ip",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
> { "error": {
> "root_cause": [
> {
> "type": "resource_already_exists_exception",
> "reason": "index [test_ip/xBXNCAjnRjODoAAY3TGFBA] already exists",
> "index_uuid": "xBXNCAjnRjODoAAY3TGFBA",
> "index": "test_ip"
> }
> ],
> "type": "resource_already_exists_exception",
> "reason": "index [test_ip/xBXNCAjnRjODoAAY3TGFBA] already exists",
> "index_uuid": "xBXNCAjnRjODoAAY3TGFBA",
> "index": "test_ip" },
>. "status": 400 }
Upvotes: 0