Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove multiple fields from index?

I would like to remove multiple fields from index for example ('person_full','company_full'). Using ES: 5.6.14

To delete one field -> following code is working well

POST firma-2019.04/_update_by_query?conflicts=proceed
{
    "script": {
        "source": "ctx._source.remove('person_full')",
        "lang": "painless"
    }
}

But I would like to delete multiple fields at once and this code does not work.

POST firma-2019.04/_update_by_query?conflicts=proceed
{
    "script": {
        "source": "ctx._source.remove('person_full','company_full')",
        "lang": "painless"
    }
}

Thank you in advance for your Help

like image 518
petrolis Avatar asked Jan 02 '23 01:01

petrolis


1 Answers

The below query should work:

POST firma-2019.04/_update_by_query?conflicts=proceed
{
    "script": {
        "source": "ctx._source.remove('person_full');ctx._source.remove('company_full')",
        "lang": "painless"
    }
}

To delete more fields add more remove statements in the script.

like image 77
TechnocratSid Avatar answered Jan 08 '23 04:01

TechnocratSid