D'oh! Thank you. Yes, I see what you mean. And, yes, you're right about what I was thinking. I'm embarrassed, but grateful for the correction.
Using mutate
to convert the data type of a field to the Elasticsearch-specific keyword
or text
type was an idea (a wrongheaded one, as you've pointed out) that occurred to me as a possible alternative to what I'm actually doing, which is to use an index template.
What I was doing in Elastic < 5.0
In Elastic 1.x and 2.x, I used the following index template to set all string fields in the index pattern fuw-* to not_analyzed
:
{
"template" : "fuw-*", 1
"mappings" : {
"_default_" : {
"dynamic_templates" : [ {
"string_fields" : {
"mapping" : {
"index" : "not_analyzed",
"omit_norms" : true,
"type" : "string"
},
"match_mapping_type" : "string",
"match" : "*"
}
} ]
}
}
}
(This works for me, and I'll likely still need to use/support Elasticsearch 2.x, so I'd gratefully accept tips.)
What I'm doing now in Elastic 5.0
In Elastic 5.0, I understand that the index
property no longer supports the value not_analyzed
.
So I'm now using the following index template to map "incoming" strings to the new-for-5.0 keyword
type:
{
"template": "fuw-*",
"mappings": {
"_default_": {
"dynamic_templates": [{
"string_fields": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}]
}
}
}
This seems to be working: for example, after loading data into that index pattern, Kibana doesn't show separate "keyword" fields in that index pattern, and I can successfully search on the "original" (non-analyzed) values.
But I'm left with a lingering doubt: in Management / Indices / Index Patterns, Kibana still shows the types of these fields in that index pattern as string
.
I expected to see these fields as type keyword
.
From the description at the top of that Kibana page:
This page lists every field in the fuw-* index and the field's associated core type as recorded by Elasticsearch.
I Googled for "core type", and found the Elastic documentation topic "Field datatypes":
Core datatypes
string
text and keyword
Based on that documentation, perhaps everything's working as designed, and Kibana is correctly reporting string
as the core type, where text
and keyword
are types that "belong" to that core type?
Or am I, once again, conflating types from different contexts?