0
Hei guys,我tryig使用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 indexspecialty
relation which is aProxies\__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
...
}
您使用的是哪個版本?自1.0.10以來,它應該正確處理:https://github.com/algolia/AlgoliaSearchBundle/blob/d5244e2623eef2aa05a8400b2e6b852784368bd7/Mapping/Loader/AnnotationLoader.php#L47如果您使用的是最新版本。你能發送完整的堆棧跟蹤嗎? – Maxime
Hi @Maxime昨天我剛剛從他們的網站下載了它(https://www.algolia.com/doc/api-client/symfony/setup/),所以它可能是最後一個版本。我將用完整的代碼更新實體,所以也許我錯過了一些東西。 –