Converting data type from string to int or from string to date

Hi all I've doing this call but how can you see data is string but I would like to convert data like ANGLE from text to a double or DATE like data fields, what's the call in order to do that?
When data is flushed again into server, will be there the same problem?

    curl -X GET "localhost:9200/test-index/_mapping?pretty"
{
  "test-index" : {
    "mappings" : {
      "properties" : {
        "ANGLE" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "DATE" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "DEGREE" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "DEPTH" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "REF" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "TIME" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "UNITS" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

Thanks for the support

You can't change the mapping of an index. But u can create a new index and mapping just like you created the existing one. Then u can use the reindex api to move the data.

So if I understood well, I need to create another index(with same label data but different data types) and then move data from one index to the other, right? Do you have an example ? I think I manage to modify the information in input, the only kind of information i need to change is the convert from string to data and string to timestamp.
Thanks for the support

Yess, see Reindex API | Elasticsearch Guide [7.12] | Elastic for how to reindex.

Sorry for the late response I 've tryed to change data type of each field from string to int or float according the usage but I don't why the index recognize by the kibana is always string. Maybe you've right I need to create like a mapping but I need to change only the datatype of the keyword of a field and in the example you provided me there're not example of datatype convert.

Maybe I manage to solve in the sense I convert data before inserting into elasticsearch according to it I manage to visualize in kibana the correct value. The only drawback is that I've convert the datatipe into a date object using the following representation:

from datetime import datetime
dateValue =datetime.datetime.strptime("01/27/2012 13:04:20","%m/%d/%Y  %H%M%S")

#now I insert dateValue as a field of the document like 
doc={'TIMESTAMP': dateValue}#here for semplicity assume there are other fields that I don't insert for semplicity
Elasticsearch().index("index-test", id=1, body=doc)

When I see on Kibana and I try to see others field how increase in comparison in time the value of the date is like a null value because it's not possible to use as field for comparison but when I go on Discover section I manage to see it.

I manage to solve it thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.