monsieurbiz / SyliusSearchPlugin

A search plugin using Elasticsearch for Sylius
MIT License
45 stars 38 forks source link

Correct `index: /<INDEX_NAME>/_doc/<ID> caused failed to parse` errors #126

Closed maximehuran closed 2 years ago

maximehuran commented 2 years ago

When a related product is loaded in another one, when we have to reindex this product, a Proxy class is loaded and the reindex causes :

  [Elastica\Exception\Bulk\ResponseException]
  Error in one or more bulk request actions:
  index: /monsieurbiz_product_fr_2022-06-02-171613/_doc/495 caused failed to parse

I dig a lot and the when it's OK the class is a Product : image

And when it's not, I have a proxy class : image

With a proxy, the Automapper does not map the product and the DTO is an empty array. This empty array generate the error.

So I created a method to be sure we have the correct entity, and not a proxy while reindexing.