samedi 3 septembre 2016

Add new field to existing index in Elasticsearch

Ok I've created an elastic search index called users that looks like this:

$response = $client->index([
        'index' => 'users',
        'type' => 'user',
        'id' => Auth::user()->id,
        'body' => [
            'username' => Auth::user()->username,
            'name' => Auth::user()->name,
            'city' => Auth::user()->getCity(),
        ],

    ]);

I already indexed some data. I want to add a new field called 'location' to this index so that it will now be:

$response = $client->index([
        'index' => 'users',
        'type' => 'user',
        'id' => Auth::user()->id,
        'body' => [
            'username' => Auth::user()->username,
            'name' => Auth::user()->name,
            'city' => Auth::user()->getCity(),
            'location' => [$origin],
        ],

    ]);

my question is how do I add that field to the already existing data. I already have users , but without the location field. I need to add that field to the old users data so that when a user updates their info, They don't get any shard missing errors



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire