Algolia搜索引擎Symfony错误

Hei guys, I'm tryig to use Algolia search. Everething works perfect, but when I try to update the engine with ORM relation, I get an error.

Here is my entity code:

    /**
     * @ORM\ManyToOne(targetEntity="Specialty", inversedBy="professionals")
     * @ORM\JoinColumn(name="specialty_id", referencedColumnName="id", onDelete="CASCADE")
     * @Algolia\Attribute
     */
    private $specialty; 

And when running

php app/console algolia:reindex AppBundle:Professional

I get an error:

[Algolia\AlgoliaSearchBundle\Exception\NotAnAlgoliaEntity]
Tried to index specialty relation which is a Proxies\__CG__\AppBundle\Entity\Specialty instance, which is not recognized as an entity to index.

Any help? Thanks.

//Full professional entity

<?php
// src/AppBundle/Entity/Professional.php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use PUGX\MultiUserBundle\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use Algolia\AlgoliaSearchBundle\Mapping\Annotation as Algolia;

/**
 * @ORM\Entity
 * @ORM\Table(name="professional")  
 * @UniqueEntity(fields = "username", targetClass = "AppBundle\Entity\User", message="fos_user.username.already_used")
 * @UniqueEntity(fields = "email", targetClass = "AppBundle\Entity\User", message="fos_user.email.already_used")
 */
class Professional extends User
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     * @Algolia\Attribute
     */
    protected $id;

    public function __construct()
    {
        $this->followers = new \Doctrine\Common\Collections\ArrayCollection();
        $this->following = new \Doctrine\Common\Collections\ArrayCollection();
        $this->degrees = new \Doctrine\Common\Collections\ArrayCollection();
        $this->experiences = new \Doctrine\Common\Collections\ArrayCollection();
        $this->favourites_clinical_cases = new ArrayCollection();
        $this->interested_in_courses = new ArrayCollection();
        $this->tags = new ArrayCollection();
        $this->subspecialties = new \Doctrine\Common\Collections\ArrayCollection();

    }

    /**
     * @ORM\Column(type="string", length=255, nullable=false)
     * @Algolia\Attribute
     */
    private $name;

    /**
     * @ORM\Column(type="string", length=255, nullable=false)
     * @Algolia\Attribute
     */
    private $surname;

    /**
     * @ORM\Column(type="string", length=255, nullable=false)
     */
    private $country;

    /**
     * @ORM\Column(type="integer", nullable=false)
     */
    private $phone;

    /**
     * @ORM\ManyToOne(targetEntity="Gender")
     * @ORM\JoinColumn(name="gender_id", referencedColumnName="id", onDelete="CASCADE")
     */
    private $gender; 

    /**
     * @ORM\ManyToOne(targetEntity="Studies")
     * @ORM\JoinColumn(name="studies_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)
     */
    private $studies;

    /**
     * @ORM\ManyToOne(targetEntity="Province")
     * @ORM\JoinColumn(name="province_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)
     */
    private $province;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Algolia\Attribute
     */
    private $out_province;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Algolia\Attribute
     */
    private $city;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $birth_place;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $zipcode;

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Assert\File(mimeTypes={ "image/jpeg", "image/png", "image/gif" })
     */
    private $image_profile;

    /**
     * @ORM\ManyToOne(targetEntity="Specialty", inversedBy="professionals")
     * @ORM\JoinColumn(name="specialty_id", referencedColumnName="id", onDelete="CASCADE")
     * @Algolia\Attribute
     */
    private $specialty; 

    /**
     * @ORM\ManyToMany(targetEntity="SubSpecialty", inversedBy="professionals")
     * @ORM\JoinColumn(name="subspecialty_user", nullable=true)
     */
    private $subspecialties; 

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $referee_number; 

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $referee_place;

    /**
     * @ORM\OneToMany(targetEntity="ClinicalCase", mappedBy="author")
     */
    private $clinical_cases;

    /**
     * @ORM\OneToMany(targetEntity="JobOffer", mappedBy="author")
     */
    //private $job_offers;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    private $about_me;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Algolia\Attribute
     */
    private $company;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     */
    private $find_job=0;

    /**
     * @ORM\Column(type="date")
     */
    private $member_from;

    /**
     * @ORM\OneToMany(targetEntity="ProfessionalExperience", mappedBy="professional", cascade={"persist"})
     */
    private $experiences;

    /**
     * @ORM\OneToMany(targetEntity="ProfessionalDegree", mappedBy="professional", cascade={"persist"})
     */
    private $degrees;

    /**
     * @ORM\ManyToMany(targetEntity="Professional", inversedBy="followers")
     * @ORM\JoinTable(name="follows")
     */
    private $following;

    /**
     * @ORM\ManyToMany(targetEntity="Clinic", inversedBy="followers")
     * @ORM\JoinTable(name="follows_clinic")
     */
    private $following_clinic;

    /**
     * @ORM\ManyToMany(targetEntity="Professional", mappedBy="following")
     */
    private $followers;

    /**
     * @ORM\OneToMany(targetEntity="Candidature", mappedBy="professional")
     */
    private $candidatures;

    /**
     * @ORM\OneToMany(targetEntity="TurnsProfessional", mappedBy="professional")
     */
    private $turns;

    /**
     * @ORM\ManyToMany(targetEntity="ClinicalCase", inversedBy="favouritedBy")
     * @ORM\JoinTable(name="favourite_clinical_case")
     */
    private $favourites_clinical_cases;

    /**
     * @ORM\ManyToMany(targetEntity="Course", inversedBy="interestedBy")
     * @ORM\JoinTable(name="courses_professionals")
     */
    private $interested_in_courses;


    // // *
    // //  * @ORM\ManyToMany(targetEntity="Specialty", cascade={"persist", "remove"})
    // //  * @ORM\JoinTable(name="tags_professional",
    // //  *      joinColumns={@ORM\JoinColumn(name="professional_id", referencedColumnName="id")},
    // //  *      inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")}
    // //  *      )
    // private $tags;


    private $terms;


    ...
     Setters i getter
    ...
}

Finally found a solution.

In relations u must set any atribute of ur subclass as Algolia atribute and persist it to the engine. I mean, in my specialty I just have to add the * @Algolia/atribute to any of the fields (name for example), and it will take the relation.