1

I have Windows machine, ElasticSearch 5.0.0 and a standard PHP client for ElasticSearch, that I installed using composer. Everything works ok, except delete operation. I can not delete by query and as a result get this error message:

Uncaught exception 'Elasticsearch\Common\Exceptions\InvalidArgumentException' with message 'id cannot be null.'

This is how I try to delete:

$client = ClientBuilder::create()->build();
$params = [
    'index' => 'layers'
    'type' => 'layers_type'
    'body' => [
        'bool' => [
            'should' => [
                [
                    'multi_match' => [
                        'query' => ["304"],
                        'fields' => ["id"] // not a surrogate _id, by my own id, that is a part of my index properties
                    ]
                ]
            ]
        ]
    ]
];
$client->delete($params);

So, how can I fix it? Do I need to install any plugin and if yes, how can I do that on my Windows machine?

0

1 Answer 1

1

The delete function requires an id since it is meant to delete a single document, that's the reason why you get that error.

In order to do what you want, you need the deleteByQuery function instead, but it has been removed in 2.x and not added back (yet).

You can use the Elastica PHP client in the meantime. It is 5.0 compliant and supports the deleteByQuery feature.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.