エンティティ「レート」と1対多の関係を持つ「記事」エンティティがあります。
私の記事はすでにインデックスされています。記事のレート平均 (記事に関連する「レート」エンティティで計算) をインデックスに追加したいのですが、これを行う方法がわかりません。また、新しいレートがある場合は平均レートを更新する必要があります。作成した。
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;