我有字段“技能”的实体映射
* @ORM\Column(name="skills", type="array", nullable=true)
* @Groups({"for_profile_project"})
*/
private $skills = [];
弹性配置(这是我的所有配置postebin)
队:
indexes:
profile:
finder: ~
types:
team:
mappings:
id:
type: integer
slug:
type: string
projects:
type: "nested"
properties:
id: ~
title:
type: string
description:
type: string
skills:
expose: true
persistence:
driver: orm
model: Artel\ProfileBundle\Entity\Teams
provider: ~
listener:
immediate: true
finder: ~
在DB中我喜欢这个
a:5:{i:0;a:2:{s:4:"lang";s:10:"JavaScript";s:7:"percent";d:44.169475214305216;}i:1;a:2:{s:4:"lang";s:3:"CSS";s:7:"percent";d:37.235383527019629;}i:2;a:2:{s:4:"lang";s:3:"PHP";s:7:"percent";d:10.312846145221229;}i:3;a:2:{s:4:"lang";s:4:"HTML";s:7:"percent";d:8.1084777328220206;}i:4;a:2:{s:4:"lang";s:10:"ApacheConf";s:7:"percent";d:0.17381738063190688;}}
当我更新实体时我有错误
Merging dynamic updates triggered a conflict: mapper [projects.skills.percent] of different type, current_type [double], merged_type [long]
我需要什么类型的野外技能或如何纠正弹性配置? 我的配置有什么问题?
我删除了弹性和运行命令中的所有inde
app/console fos:elastica:populate --no-reset
现在我有了这个映射
"team": {
"properties": {
"skills": {
"type": "string"
},
"webSite": {
"type": "string"
},
"createdAt": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"projects": {
"properties": {
"cost": {
"type": "long"
},
"authorId": {
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"id": {
"type": "long"
},
"username": {
"type": "string"
}
}
},
"skills": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
现在我用一种技能创建测试项目(a:1:{i:0; s:6:“技能”;}}但是只有当我编辑实体团队或运行命令时才自动上传弹性
app/console fos:elastica:populate --no-reset
当我用
添加真实项目时a:5:{i:0;a:2:{s:4:"lang";s:10:"JavaScript";s:7:"percent";d:44.169475214305216;}i:1;a:2:{s:4:"lang";s:3:"CSS";s:7:"percent";d:37.235383527019629;}i:2;a:2:{s:4:"lang";s:3:"PHP";s:7:"percent";d:10.312846145221229;}i:3;a:2:{s:4:"lang";s:4:"HTML";s:7:"percent";d:8.1084777328220206;}i:4;a:2:{s:4:"lang";s:10:"ApacheConf";s:7:"percent";d:0.17381738063190688;}}
并运行
app/console fos:elastica:populate --no-reset
或者当我为这个实体团队添加嵌套实体开发人员时,我有错误:
Notice: Array to string conversion
mapper_parsing_exception
failed to parse [projects.skills]
illegal_argument_exception
unknown property [lang]
我尝试将百分比设置为整数但仍有错误
a:5:{i:0;a:2:{s:4:"lang";s:10:"JavaScript";s:7:"percent";d:44;}i:1;a:2:{s:4:"lang";s:3:"CSS";s:7:"percent";d:37;}i:2;a:2:{s:4:"lang";s:3:"PHP";s:7:"percent";d:10;}i:3;a:2:{s:4:"lang";s:4:"HTML";s:7:"percent";d:8;}i:4;a:2:{s:4:"lang";s:10:"ApacheConf";s:7:"percent";d:0;}}
我试试
skills:
expose: true
properties:
lang:
type: string
percent:
type: double
但仍然有
Notice: Array to string conversion
mapper_parsing_exception
failed to parse [projects.skills]
illegal_argument_exception
unknown property [lang]
更新
现在我删除了索引并更改了这样的配置:
skills:
properties:
lang:
type: string
percent:
type: double
并且有弹性
"skills": {
"properties": {
"lang": {
"type": "string"
},
"percent": {
"type": "double"
}
}
},
当我上传具有如下字段技能的实体时:
a:5:{i:0;a:2:{s:4:"lang";s:10:"JavaScript";s:7:"percent";d:44.169475214305216;}i:1;a:2:{s:4:"lang";s:3:"CSS";s:7:"percent";d:37.235383527019629;}i:2;a:2:{s:4:"lang";s:3:"PHP";s:7:"percent";d:10.312846145221229;}i:3;a:2:{s:4:"lang";s:4:"HTML";s:7:"percent";d:8.1084777328220206;}i:4;a:2:{s:4:"lang";s:10:"ApacheConf";s:7:"percent";d:0.17381738063190688;}}
一切都好,但是当我用字段
创建实体时a:1:{i:0;s:8:"skills23";}
我有错误
更新
skills:
expose: true
github:
properties:
lang:
type: string
percent:
type: double
为什么字段github不能用弹性创建我不明白 (这是我的所有配置postebin)
答案 0 :(得分:1)
"skills": {
"type": "string"
},
在您的映射中定义为字符串,但在您的数据技能中是一个包含密钥lang和百分比的数组,因此您的技能部分映射应该是。
"skills": {
"properties" : {
"lang" : {
"type" : "string"
},
"percent" : {
"type" : "double"
},
}
},
编辑:它应该有用。
indexes:
profile:
finder: ~
types:
team:
mappings:
id:
type: integer
slug:
type: string
projects:
type: "nested"
properties:
id: ~
title:
type: string
description:
type: string
skills:
properties:
lang:
type: string
percent:
type: double
persistence:
driver: orm
model: Artel\ProfileBundle\Entity\Teams
provider: ~
listener:
immediate: true
finder: ~