2017-03-06 7 views
0

Hei guys、私はAlgolia検索を使用しようとしています。 Everethingは完璧に動作しますが、ORM関係でエンジンを更新しようとすると、エラーが発生します。 Algolia検索エンジンSymfonyエラー

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

php app/console algolia:reindex AppBundle:Professional

を実行しているとき、私はエラーを取得する:ここで

は私のエンティティコードです

[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.

任意のヘルプ?ありがとう。

//完全なプロのエンティティ

<?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 
    ... 
} 
+0

お使いのバージョンは? 1.0.10以降は正しく処理する必要があります:https://github.com/algolia/AlgoliaSearchBundle/blob/d5244e2623eef2aa05a8400b2e6b852784368bd7/Mapping/Loader/AnnotationLoader.php#L47最新バージョンを使用している場合は、あなたは完全なスタックトレースを送ることができますか? – Maxime

+0

こんにちは@Maxime昨日、自分のWebサイト(https://www.algolia.com/doc/api-client/symfony/setup/)からダウンロードしたので、最後のバージョンかもしれません。エンティティを完全なコードで更新するので、何か不足している可能性があります。 –

答えて

0

は最後に解決策を見つけました。

関係では、urサブクラスの属性をAlgolia属性として設定し、それをエンジンに保持する必要があります。私の専門分野では、* @Algolia/atributeを任意のフィールド(名前など)に追加するだけで、関係になります。