IanRC72
(Ian Campbell)
January 31, 2018, 4:55pm
1
I ran the following sample from this page :
PUT my_index
{
"mappings": {
"my_type": {
"dynamic_templates": [
{
"longs_as_strings": {
"match_mapping_type": "string",
"match": "long_*",
"unmatch": "*_text",
"mapping": {
"type": "long"
}
}
}
]
}
}
}
PUT my_index/my_type/1
{
"long_num": "5",
"long_text": "foo"
}
The result:
GET my_index/_search
...
{
"_index": "my_index",
"_type": "my_type",
"_id": "1",
"_score": 1,
"_source": {
"long_num": "5",
"long_text": "foo"
}
}
I was expecting long_num to be of type long not string.
Am I missing something here?
warkolm
(Mark Walkom)
February 2, 2018, 12:41am
2
What does the mapping look like? That is, what does GET my_index/_mapping
show.
IanRC72
(Ian Campbell)
February 2, 2018, 4:59pm
3
warkolm:
GET my_index/_mapping
{
"my_index": {
"mappings": {
"my_type": {
"dynamic_templates": [
{
"longs_as_strings": {
"match": "long_*",
"unmatch": "*_text",
"match_mapping_type": "string",
"mapping": {
"type": "long"
}
}
}
],
"properties": {
"long_num": {
"type": "long"
},
"long_text": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
IanRC72
(Ian Campbell)
February 3, 2018, 8:14am
5
Yes, but the output doesn't:
"_source": {
"long_num": "5",
"long_text": "foo"
}
Somehow it's mapped as a long but displayed (stored?) as a string. That doesn't make sense.
dadoonet
(David Pilato)
February 3, 2018, 9:21am
6
Elasticsearch never transforms the source document.
For example when you index a date "2018-02-03" it is indexed internally as a number but when you get back the source, it won't be a number but the exact string you sent.
1 Like
IanRC72
(Ian Campbell)
February 3, 2018, 9:26am
7
Ah, that makes sense. Thanks much for explaining this.
system
(system)
Closed
March 3, 2018, 9:27am
8
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.