我将我的索引定义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. 这是与@ManyToOneBrend
相关联的方式User
/**
* @ORM\ManyToOne(targetEntity="Minn\UserBundle\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
仅供参考: 2. 我正在使用dev-master
FOSElasticaBundle 和 Elastica 的分支。对于elasticsearch,我使用的是2.1.1。
填充命令php app/console fos:elastica:populate
总是返回此错误:
[Elastica\Exception\ResponseException]
{"root_cause":[{"type":"mapper_parsing_exception","reason":"[user] 的映射定义有不受支持的参数:[store : true]"}],"type": "mapper_parsing_exception","reason":"解析映射 [brand] 失败:
[user] 的映射定义具有不受支持的参数:[store : true]","caused_by":{"type":"mapper_parsing_exception","reason" :"[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","商店":true}},"商店":true}},"dynamic_date_formats":[],"_meta":{"model":"Minn\AdsBundle\Entity\Brend"}}}},"query":[],"connection":{"config":{"headers": []},"host":"127.0.0.1","port":9200,"logger":"fos_elastica.logger","enabled":true}} []
下面是带有额外的映射"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!
}
}
}
}
}