1
votes

I use FOSElasticaBundle in my Symfony 2 project. Since today reindexing is resulting in the below error:

index: /app/hotel/1 caused MapperParsingException[failed to parse [priceFrom]]; nested: NumberFormatException[For input string: "410.00"];

In my doctrine orm yml the priceFrom field is defined as followed:

priceFrom:
   type: decimal
   nullable: true
   precision: 7
   scale: 2
   comment: ''
   column: price_from

My fos_elastica config looks like this (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: ~           

The command I use to reindex: php app/console fos:elastica:populate

The above setup has worked until now. I hope someone can point my to the good direction to solve this problem.

Versions: ruflin/elastica (2.1.0) friendsofsymfony/elastica-bundle (v3.1.5) symfony/symfony (v2.6.11)

PS: No other entities in my project are using a priceFrom field.

2

2 Answers

0
votes

In mappings, you define PriceFrom as integer but then you pass a decimal.

I haven't tested it but it definitely seems the major candidate as the culprit.

0
votes

Francesco Abeni is right with answer. If you are already pushed something in ES as integer (or ES defined it as integer) it will generate exception when you will try to save decimal data here.

I always explicitly specify type in mapping like:

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

There I see two ways to solve problem.

  1. index alias and index merge
  2. specify type in mapping; kill index; populate in again

I used second variant on a dev :)