I defined my index ads
as follows:
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: ~
FYI: 1. This is how Brend
is linked with User
with @ManyToOne
/**
* @ORM\ManyToOne(targetEntity="Minn\UserBundle\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
FYI: 2. I am using the dev-master
branches for FOSElasticaBundle and Elastica. For elasticsearch, I am using 2.1.1.
A populate command php app/console fos:elastica:populate
always returns this error:
[Elastica\Exception\ResponseException]
{"root_cause":[{"type":"mapper_parsing_exception","reason":"Mapping definition for [user] has unsupported parameters: [store : true]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [brand]:
Mapping definition for [user] has unsupported parameters: [store : true]","caused_by":{"type":"mapper_parsing_exception","reason":"Mapping definition for [user] has unsupported parameters: [store : true]"}}
I checked the app/logs/dev.log
, I found that the generated mapping for the index ads
has an extra parameter "store":true
. You can check that down:
[2015-12-20 21:28:21] elastica.DEBUG: logging Request {"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":[]},"host":"127.0.0.1","port":9200,"logger":"fos_elastica.logger","enabled":true}} []
Below is the mapping with the extra "store": true
. Is there any idea on how to configure FOSElasticaBundle to get a mapping without this extra line with "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!
}
}
}
}
}