2017-06-13 16 views
0

の設定アナライザ。FOSElasticaBundle:私はsymfonyの3.3でFOSElasticaBundleを使用していますカスタムプロパティ

public function addCustomProperty(TransformEvent $event) 
{ 
    $document = $event->getDocument(); 
    $custom = $this->anotherService->calculateCustom($event->getObject()); 

    $document->set('custom', $custom); 
} 

今、私は、このプロパティに使用するアナライザを設定する必要があります:私は計算し、このようなadds a custom propertyがPOST_TRANSFORMイベントにイベントリスナーを登録しています。どうやってやるの?

私はfos_elastica configの型定義にカスタムフィールド名を追加しようとしましたが、バンドルがそのプロパティを自分のエンティティでも期待しているため、例外が発生します。

答えて

0

私は最終的に私はこのような希望アナライザを設定するためにdynamic_templatesを使用できることが判明:

fos_elastica: 
    indexes: 
    app: 
     types: 
     myentity: 
      dynamic_templates: 
      custom_field: 
       path_match: customfield.* 
       mapping: 
       analyzer: myanalyzer 
      properties: 
      ... 
関連する問題