Algolia搜索引擎Symfony错误

时间:2017-03-06 11:24:26

标签: php symfony algolia

嘿伙计们,我尝试使用Algolia搜索。 Everething工作得很完美,但是当我尝试用ORM关系更新引擎时,我收到错误。

这是我的实体代码:

specialty

运行时

  

php app / console algolia:reindex AppBundle:Professional

我收到错误:

  

[Algolia \ AlgoliaSearchBundle \异常\ NotAnAlgoliaEntity]
  试图索引Proxies\__CG__\AppBundle\Entity\Specialty关系是一个   <?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 ... } 实例,不是   被认可为索引的实体。

有任何帮助吗?感谢。

//完整的专业实体

{{1}}

1 个答案:

答案 0 :(得分:0)

终于找到了解决方案。

在关系中你必须将ur子类的任何属性设置为Algolia属性并将其持久保存到引擎中。我的意思是,在我的专长中,我只需要将* @Algolia/atribute添加到任何字段(例如名称),它将采用这种关系。