我有一个“文章”实体,它与实体“率”有一对多的关系。
我的文章已经被索引了。我想将文章的平均费率添加到索引中(使用与文章相关的“费率”实体计算),我不知道如何执行此操作,如果新费率是,则必须更新平均费率创建的。
对于 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;