How to enable “numerical detection string”?
By setting numeric_detection
to true:
PUT my-index
{
"mappings": {
"numeric_detection": true
}
}
, the following fields field1 and field2 will be mapped as float type and long type, rather than text type:
PUT my-index/_doc/1
{
"field1": "1.0",
"field2": "1"
}
(post deleted by author)
- Can you recognize certain parts as correct letters and approximate numbers?
PUT my-index
{
"mappings": {
"properties": {
"year": { "type" : "text" },
"age": { "type" : "text", "numeric_detection": true },
"director":{ "type" : "text", "numeric_detection": true }
}
}
}
RESPONSE
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "my-index"
}
- If you put in a large number, the correct value is text, and is it recognized as a number recognized as an approximate double or scale float value?
PUT /my-index_doc/1
{
"year": "99999999999999999999",
"age": "99999999999999999999.99999999999999999999",
"director": "ABC"
}
GET /my-index/_search
{
"took": 14,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "my-index",
"_id": "1",
"_score": 1,
"_ignored": [,
],
"_source": {
"year": "99999999999999999999",
"age": "99999999999999999999.99999999999999999999",
"director": "ABC"
}
}
]
}
}