Update by query

create by bluk, after update by quey => update run but not updated
Timeout is 2m => not updated
Can you help me? I using php client

You need to share more information if you want help.

Like:

  • the requests and the responses
  • elasticsearch logs

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

My process:
Create by bulk

    $params = [];
    $index = $this->model->getIndexName();
    $type = $this->model->getTable();
    foreach ($list as $hashtag) {
        $hashtag->number_member = 0;
        $hashtag->number_feed = 0;
        $hashtag->cover_hashtag = new \stdClass();
        $hashtag->is_new =0;
        $hashtag->time_new = 0;
        $params['body'][] = array(
            'index' => array(
                '_id' => $hashtag->id,
                '_type' => $type,
                '_index' => $index,
            )
        );
        $params['body'][] = (array)$hashtag;

    }
    try {
        $client = ClientBuilder::create()->build();
        $client->bulk($params);
    } catch (\Throwable $throwable) {
    }

after update by query

$script = "ctx._source['number_member']=params.member.containsKey(ctx._id)?params.member[ctx._id]:ctx._number_member";

$client = ClientBuilder::create()->build();
        $params = [
            'index' => $this->model->getIndexName(),
            'type' => $this->model->getTable(),
            'body' => [
                'query' => [
                    'bool' => [
                        'must' => $this->filterIn('id', $hashtagIds)
                    ]
                ],
                'script' => [
                    'inline' => $script,
                    'lang' => 'painless',
                    'params' => [
                        'member' => $members
                    ]
                ]
            ],
        ];
        try {
            $client->updateByQuery($params);
        } catch (\Throwable $throwable) {
        }

Documents that have just been created by bluk cannot update its value. Still other documents are still updated

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