我有一個「物品」實體,它與實體「rate」具有一對多關係。在symfony2上使用彈性搜索(FOSElasticaBundle)對計算字段進行索引
我的文章已經編入索引。我想添加索引文章的費率平均值(用與文章相關的「費率」實體計算),並且我不知道如何做到這一點,如果新費率是創建。
在config.yml映射:
indexes:
piy:
client: default
settings:
index:
analysis:
analyzer:
custom_search_analyzer:
type: custom
tokenizer: standard
filter : [standard, lowercase, asciifolding]
custom_index_analyzer:
type: custom
tokenizer: standard
filter : [standard, lowercase, asciifolding, custom_filter]
filter:
custom_filter:
type: edgeNGram
side: front
min_gram: 1
max_gram: 20
types:
article:
mappings:
title : { search_analyzer: custom_search_analyzer, index_analyzer: custom_index_analyzer, type: string }
user:
type : object
properties :
fullName : { search_analyzer: custom_search_analyzer, index_analyzer: custom_index_analyzer, type: string }
persistence:
driver: orm
model: Piy\CoreBundle\Entity\Article
elastica_to_model_transformer:
service: piy.transformers.elastica.article
finder: ~
provider: ~
listener: ~
和速度實體映射:
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="integer", length=1)
*/
private $value;
/**
* @ORM\ManyToOne(targetEntity="Piy\CoreBundle\Entity\User", inversedBy="articleRates")
*/
public $user;
/**
* @ORM\ManyToOne(targetEntity="Piy\CoreBundle\Entity\Article", inversedBy="rates")
*/
private $article;
您可以在config.yml中提供您當前的映射嗎?此外,我們需要知道您的實體的結構(至少比率) – Javad
謝謝;現在,您想要對您的費率實體的哪些字段進行索引?我需要實體映射(只是結構) – Javad
我想索引與文章 – user3328275