Symfony 弹性映射
Symfony Elastic mapping
我有字段 "skills"
的实体映射
* @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: ~
在数据库中我有这样的
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]
我需要什么类型的现场技能或如何更正弹性配置?
我的配置有什么问题?
我删除了 elastic 和 运行 命令中的所有索引
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:"skills";}),但只有当我编辑实体团队或运行 命令
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 不能在 elastic 中创建 我不明白
(这是我所有的配置postebin)
"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: ~
我有字段 "skills"
的实体映射 * @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: ~
在数据库中我有这样的
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]
我需要什么类型的现场技能或如何更正弹性配置? 我的配置有什么问题?
我删除了 elastic 和 运行 命令中的所有索引
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:"skills";}),但只有当我编辑实体团队或运行 命令
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 不能在 elastic 中创建 我不明白 (这是我所有的配置postebin)
"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: ~