태그가 많은 래서 피 엔티티가 있으며 태그로 래서 피를 검색하려고합니다.Elastica Search 및 Symfony2를 사용하여 중첩 쿼리를 수행하는 방법
다음/**
* @ORM\Entity
* @ORM\Table(name="recipes")
* @ORM\HasLifecycleCallbacks
* @ExclusionPolicy("all")
*/
class Recipe
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @Expose
*/
protected $id;
/**
* @ORM\Column(type="string", length=150)
* @Expose
*/
protected $name;
...
/**
* @ORM\ManyToMany(targetEntity="RecipesTag", inversedBy="recipes")
* @ORM\JoinTable(name="bind_recipes_tags",
* joinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="recipe_id", referencedColumnName="id")}
* )
*/
private $tags;
내 설정이다 :
가 여기 내 레시피 기업의
public function filterFind($searchText)
{
$query_part = new \Elastica\Query\Bool();
$nested = new \Elastica\Query\Nested();
$nested->setQuery(new \Elastica\Query\Term(array('name' => array('value' => $searchText))));
$nested->setPath('tags');
$query_part->addShould($nested);
return $this->find($query_part);
}
그럼 난 이렇게 검색 : 다음 검색을 수행 할 수있는 사용자 정의 저장소를 추가
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
serializer:
callback_class: FOS\ElasticaBundle\Serializer\Callback
serializer: serializer
indexes:
td:
client: default
types:
Recipe:
mappings:
name: ~
ingredients:
type: "nested"
properties:
name: ~
tags:
type: "nested"
properties:
name: ~
id :
type : integer
categories:
type: "nested"
properties:
name: ~
id :
type : integer
persistence:
driver: orm # orm, mongodb, propel are available
model: ck\RecipesBundle\Entity\Recipe
repository: ck\RecipesBundle\Entity\RecipesRepository
provider: ~
listener: ~
finder: ~
:
$repositoryManager = $this->get('fos_elastica.manager.orm');
$repository = $repositoryManager->getRepository('ckRecipesBundle:Recipe');
$recipes = $repository->filterFind('mytag');
하지만 일치하는 결과가 있음에도 불구하고 아무런 결과가 없습니다.
Google에 대한 답변을 찾지 못했습니다. 누구든지 나를 도울 수 있습니까?
당신이 그것을 resovled 했습니까? 대답은 좋은가요? – goto