我在我的Symfony 2项目中使用FOSElasticaBundle。由于今天重新编制索引会导致以下错误:
索引: /app/hotel/1导致MapperParsingException[未能解析priceFrom];嵌套: NumberFormatExceptionFor输入字符串:"410.00";
在我的理论或yml中,priceFrom字段的定义如下:
priceFrom:
type: decimal
nullable: true
precision: 7
scale: 2
comment: ''
column: price_from我的fos_elastica配置如下(config.yml)所示:
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
app:
types:
hotel:
mappings:
id: ~
active: ~
priceFrom: { type: integer }
persistence:
driver: orm
model: XXX\XXXBundle\Entity\Hotel
provider: ~
listener:
immediate: ~
finder: ~ 用于重新索引的命令:php app/console fos:elastica:populate
到目前为止,上述设置已经开始工作了。我希望有人能给我指明解决这个问题的好方向。
版本: ruflin/elastica (2.1.0) friendsofsymfony/elastica-bundle (v3.1.5) symfony/symfony (v2.6.11)
PS:我的项目中没有其他实体使用priceFrom字段。
发布于 2015-08-19 14:56:20
弗朗西斯科·阿贝尼的回答是对的。如果您已经将ES中的某些内容推送为整数(或者ES将其定义为整数),则当您尝试在这里保存十进制数据时,它将生成异常。
在映射中,我总是显式地指定类型,例如:
id: {"type" : "integer"}
shop_id: {"type" : "integer"}
source: {"type" : "string", "index" : "not_analyzed"}在这里,我看到了解决问题的两种方法。
我在dev :上使用了第二个变体
https://stackoverflow.com/questions/31947836
复制相似问题