Reputation: 2790
I have an index elasticsearch with a mapping:
{
"book": {
"mappings": {
"educational": {
"properties": {
"price": {
"type": "float"
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
Now I can index a document with instead of a float, a string:
{
"title": "Test",
"price": "120.99"
}
The value of price will be presented as a string when I will retrieve this document later, despite the fact that the mapping say it should be a float.
I know that the price will still be indexed as a float despite the fact that it is presented as a string but is there a way to force a casting of the field into a float to have a better coherence in the data?
Upvotes: 1
Views: 1974
Reputation: 1804
internally the field will be stored as a float, when coercing is used. However the original document will not be changed, which means the original JSON will still contain the field as a string.
You could use a convert processor in a pipeline to change the string to a float before the document is being indexed.
Upvotes: 1