floriansemm / SolrBundle

Solr-Integration into Symfony and Doctrine2
http://floriansemm.github.io/SolrBundle
MIT License
123 stars 73 forks source link

Problem with image indexation #144

Closed faahren closed 7 years ago

faahren commented 8 years ago

Hi. I have an image pb. The indexation works fine and I see the image name in the Solr Admin panel, but when I query (simply) my collection, the hydratation of the image fails:

Type error: Argument 1 passed to TT\GuidesBundle\Entity\Guide::setImage() must be an instance of TT\GuidesBundle\Entity\Image, string given

I even tried to create a special getter to get the object in my image class, but when I try to index it it says that a string is awaited.So, I have to index a string relation, I guess that's pretty logical.

I tried with either DOCTRINE or INDEX hydratation modes

Any idea why I get this problem ? Thanks a lot for your help Guillaume

faahren commented 8 years ago

Please find below my relation declaration in my Guide class:

/**    
 *
 * @Solr\Field(type="string", getter="getName")     
 * @ORM\ManyToOne(targetEntity="TT\GuidesBundle\Entity\Image", cascade="persist")
 */
private $image;  

Cheers, G

floriansemm commented 8 years ago

You should remove the type-hint from setImage(). Use hydration-mode DOCTRINE in your case.