Hi,
I want to add custom fields (Year, Yearly Week, Week, Month, Exist (a boolean value)) and their corresponding values into an ES index using API. SInce, I am running the OpenDistro for Elasticsearch version which doesn't have the Add field in Kibana under Index Pattern settings.
So, I tried using Elasticsearch PUT, POST APIs for updating mappings for adding the custom fields and their corresponding values. But both the custom fields and values didn't appear in the Index although the added fields did appear in the Index Pattern setting under Stack Management of the particular Index to which the custom fields were added and when the "Hide missing fields" option was unchecked only then the custom fields appeared in the index.
Following different APIs were used:
PUT vulns
{
"mappings": {
"numeric_detection": true
}
}
PUT vulns/_doc/1
{
"my_float": "120.00",
"my_integer": "100"
}
PUT /vulns/_doc/1
{
"title": "This doc adds a new field",
"stash": { "new_field": "Success!" }
}
POST vulns/_doc
{
"Year": 2023,
"Week": 20,
"Yearly_Week": 202305,
"Month": 5,
"Exist": true
}
PUT _index_template/template-1
{
"index_patterns": ["vulns*"],
"template": {
"mappings": {
"properties": {
"Year": {
"type": "integer"
},
"Week": {
"type": "integer"
},
"Yearly_Week": {
"type": "integer"
},
"Month": {
"type": "integer"
},
"Exist": {
"type": "boolean"
}
}
}
}
}
POST vulns/_doc
{
"Year": 2023,
"Week": 20,
"Yearly_Week": 202305,
"Month": 5,
"Exist": true
}
POST vulns/_bulk
{ "index" : {} }
{ "Year": 2023, "Week": 20, "Yearly_Week": 202305, "Month": 5, "Exist": true, "Exit": false }
I tried all of the above-mentioned methods but still failed to achieve my goal. Kindly suggest me a way using which I can easily add custom fields and their corresponding values to an Index.
Thanks & Regards