1

我在我的 Symfony 2 项目中使用 FOSElasticaBundle。由于今天重新索引导致以下错误:

index: /app/hotel/1 导致 MapperParsingException[failed to parse [priceFrom]]; 嵌套:NumberFormatException[对于输入字符串:“410.00”];

在我的学说 orm 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 字段。

4

2 回答 2

0

在映射中,您将 PriceFrom 定义为整数,然后传递一个小数

我没有测试过它,但它肯定是罪魁祸首的主要候选人。

于 2015-08-12T09:21:24.750 回答
0

Francesco Abeni 的回答是正确的。如果您已经在 ES 中将某些内容推送为整数(或 ES 将其定义为整数),当您尝试在此处保存十进制数据时,它将产生异常。

我总是在映射中明确指定类型,例如:

 id: {"type" : "integer"}
 shop_id: {"type" : "integer"}
 source: {"type" : "string", "index" : "not_analyzed"}

在那里我看到了两种解决问题的方法。

  1. 索引别名和索引合并
  2. 在映射中指定类型;杀戮指数;再次填充

我在开发人员上使用了第二个变体:)

于 2015-08-19T14:56:20.743 回答