I have the following code which checks if product exists in the index and if it exists it try to delete it.
But exists method always gives me true. I never index the product. so when it try to do some action like get or delete, it gives 404 error
404 Not Found: {"_index":"products","_id":"644f9549c911b","found":false}
here is my code:
$params = ['id' => $product->uid, 'index' => 'products'];
// check if the document exists in the index
$product_exists = $this->client->exists($params);
if ($product_exists) {
// specify the version of the document to delete
// here I get 404
$params['version'] = $this->client->get($params)['_version'];
// delete the document from the index
$this->client->delete($params);
Log::info("Product deleted from the index.");
} else {
Log::info("Product does not exist in the index.");
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.