Search code examples
phpsymfonyelasticsearchfoselasticabundle

Symfony Elasticsearch configuration file is not working with 1 index for multiple types


I have the following configuration in my config.yml

fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }
    indexes:      
        app:
            finder: ~            
            types:
                product:
                    properties:
                        name: ~
                        sku: ~
                    persistence:
                        driver: orm
                        model: AppBundle\Entity\Product
                        provider: ~
                        finder: ~
                stock:
                    properties:
                        sku: ~
                        stock: ~
                    persistence:
                        driver: orm
                        model: AppBundle\Entity\ProductStock
                        provider: ~
                        finder: ~

Error

Rejecting mapping update to [app] as the final mapping would have more than 1 type: [stock, product]

If I check the documentation I see the following on there Github page documentation

What am I doing wrong?


Solution

  • It is not a a fault of Symfony integration. Reason is removal of support of multiple types per index introduced by Elasticsearch back in 6.0. You need to update your index definition to only have single type of data per index.