Adding new field to existing index in ES 5.6

Hi,

I have created a index with 3 field using CSV files.
Now I want to add another 2 fields in to the index is this possible?

current fields
date, country, customer, count.

new fields
date, country, customer, under_tshold, count, tshold.

can anyone help here?

thanks,
Sridhar. B

Yes it's possible.

Hi @Sridhar

You can do this to add for example, a field "date" in existing doc:

POST nameindex/typeindex/docindex/_update?pretty
{
"doc": {
"date" : "2017/01/10"
}

Hi,

can you help me how to find this typeindex and docindex?

I'm very new to elastic search.

I want to one the field with data [value] to it.

Thanks,
Sridhar. B

Hi,

below is the actual example.

current data in ElasticSearch:

    "_index": "test",
    "_type": "logs",
    "_id": "AWDgIKFCvg3odC71dRbc",
    "_score": 0.09685399,
    "_source": {
      "HighTH": 120000,
      "@timestamp": "2018-01-10T12:52:02.684Z",
      "Cust": 16926,
      "application": "myapps",
      "@version": "1",
      "host": "localhost",
      "Run_date": "2018-01-03T16:00:00.000Z",
      "LowTH": 10000,
      "message": "04-JAN-2018,MN,16926,206472,15785,120000,10000",
      "Trans": 206472,
      "Cntry_code": "NO",
      "Trans_GPS": 15785
    }

want to update new like this.. [added mkvalue: 209845] in below example.

    "_index": "test",
    "_type": "logs",
    "_id": "AWDgIKFCvg3odC71dRbc",
    "_score": 0.09685399,
    "_source": {
      "HighTH": 120000,
      "@timestamp": "2018-01-10T12:52:02.684Z",
      "Cust": 16926,
      "application": "myapps",
      "@version": "1",
      "host": "localhost",
      "Run_date": "2018-01-03T16:00:00.000Z",
      "LowTH": 10000,
      "message": "04-JAN-2018,MN,16926,206472,15785,120000,10000",
      "Trans": 206472,
      "Cntry_code": "NO",
      "Trans_GPS": 15785,
      "mkValue": 209845

}

how to update this "mkvalue" in Elastic search in test index with value 209845 ??

thanks,
Sridhar. B

Hi!

POST test/logs/AWDgIKFCvg3odC71dRbc/_update?pretty
{
"doc": {
"mkvalue" : "209845"
}

Even better is to do:

PUT test/logs/AWDgIKFCvg3odC71dRbc
{
      "HighTH": 120000,
      "@timestamp": "2018-01-10T12:52:02.684Z",
      "Cust": 16926,
      "application": "myapps",
      "@version": "1",
      "host": "localhost",
      "Run_date": "2018-01-03T16:00:00.000Z",
      "LowTH": 10000,
      "message": "04-JAN-2018,MN,16926,206472,15785,120000,10000",
      "Trans": 206472,
      "Cntry_code": "NO",
      "Trans_GPS": 15785,
      "mkValue": 209845
}

Yeah!

@Sridhar update API is very expansive for ES. If you can, use PUT and overwritte a doc.

1 Like

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