1

adsインデックスを次のように定義しました。

fos_elastica:
    clients:
         default: { host: %elastica_host%, port: %elastica_port% }         
    indexes:
          ads:
            types:                        
                brand:
                    mappings:
                        name:
                            type: string
                            boost: 5
                        slug:
                            type: string
                            boost: 4
                        date : ~
                        isPublished: ~
                        user:
                            type: nested
                            properties: 
                                username: ~
                                email: ~
                    persistence:
                        driver: orm
                        model: Minn\AdsBundle\Entity\Brend
                        elastica_to_model_transformer:
                            service: minn_ads.transformers_elastica.brand
                        provider: ~
                        listener:
                            immediate: ~
                        finder: ~

参考までに: 1. @ManyToOne とのBrendリンク方法は次のとおりです。User

/**
 * @ORM\ManyToOne(targetEntity="Minn\UserBundle\Entity\User")
 * @ORM\JoinColumn(nullable=false)
 */
private $user;

参考までに: 2. dev-masterFOSElasticaBundle と Elastica のブランチを使用しています。Elasticsearch には 2.1.1 を使用しています。

populate コマンドphp app/console fos:elastica:populateは常に次のエラーを返します。

[Elastica\Exception\ResponseException]
{"root_cause":[{"type":"mapper_parsing_exception","re​​ason":"[user] のマッピング定義にサポートされていないパラメーターがあります: [store : true]"}],"type": "mapper_parsing_exception","re​​ason":"マッピングの解析に失敗しました [brand]:
[user] のマッピング定義にサポートされていないパラメーターがあります: [store : true]","caused_by":{"type":"mapper_parsing_exception","re​​ason" :"[user] のマッピング定義にサポートされていないパラメーターがあります: [store : true]"}}

を確認したapp/logs/dev.logところ、インデックス用に生成されたマッピングにads余分なパラメータが含まれていることがわかりました"store":true。あなたはそれをチェックすることができます:

[2015-12-20 21:28:21] elastica.DEBUG: ロギング リクエスト {"path":"ads/","method":"PUT","data":{"mappings":{"brand": {"properties":{"name":{"type":"string","boost":5,"store":true},"slug":{"type":"string","boost":4 ,"store":true},"date":{"type":"string","store":true},"isPublished":{"type":"string","store":true},"user ":{"type":"nested","properties":{"username":{"type":"string","store":true},"email":{"type":"string"," store":true}},"store":true}},"dynamic_date_formats":[],"_meta":{"model":"Minn\AdsBundle\Entity\Brend"}}}},"query":[],"connection":{"config":{"headers": []},"ホスト":"127.0.0.1","ポート":9200,"ロガー":"fos_elastica.logger","有効":true}} []

以下は、 extra を使用したマッピング"store": trueです。この余分な行を使用せずにマッピングを取得するように FOSElasticaBundle を構成する方法についてのアイデアはあります"store": trueか?

{
    "mappings": {
        "brand": {
            "properties": {
                "name": {
                    "type": "string",
                    "boost": 5,
                    "store": true
                },
                "slug": {
                    "type": "string",
                    "boost": 4,
                    "store": true
                },
                "date": {
                    "type": "string",
                    "store": true
                },
                "isPublished": {
                    "type": "string",
                    "store": true
                },
                "user": {
                    "type": "nested",
                    "properties": {
                        "username": {
                            "type": "string",
                            "store": true
                        },
                        "email": {
                            "type": "string",
                            "store": true
                        }
                    },
                    "store": true  # extra line! If deleted, it will work!
                }
            }
        }
    }
}
4

2 に答える 2