_update_by_query with PHP API

I am looking for some examples or documentation to help me know if it is possible to do a _update_by_query with the PHP API. I have seen examples in the JS section, but I can't find anything on the subject in PHP

Using curl or kibana

        POST analyzers/_update_by_query
        {
            "script": {
            "source": "ctx._source.name = 'Cambiame'",
            "lang": "painless"
          },
          "query": {
            "term": {
                "modem_id": {
                    "value": 1
              }
            }
          }
        }

Hello @abkrim

This post can help you.

1 Like

A lot of thanks.

10 minutes ago, I see the post and modify my code.

$params = [
            'index' => 'analyzers',
            'body' => [
                'query' => [
                    'term' => [
                        'modem_id' => $modem_id
                    ]
                ],
                'script' => [
                    'lang' => 'painless',
                    'source' => "ctx._source.$field_change = params.$field_change",
                    'params' => [
                        $field_change => $value_change_me
                    ]
                ]
            ]
        ];

Work fine...

1 Like

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