Adding new field to existing index in ES 5.6


(Sridhar B) #1

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


(David Pilato) #2

Yes it's possible.


(Fram Souza) #3

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"
}


(Sridhar B) #4

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


(Sridhar B) #5

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


(Fram Souza) #6

Hi!

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


(David Pilato) #7

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
}

(Fram Souza) #8

Yeah!

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


(system) #9

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