FOSElasticaBundle icon indicating copy to clipboard operation
FOSElasticaBundle copied to clipboard

Bug with keyword indexing with an array field

Open murilozilli opened this issue 3 years ago • 1 comments

FOS/Elastic version: 5.1.x-dev

Issue happens if we use type: keyword alongside a array Doctrine field type.

This is our setup:

 types:
                recruiters:
                    properties:
                        roleTypes:
                            type: keyword

Than on our annotations:


    /**
     * @ORM\Column(type="array", nullable=true)
     */
    private $roleTypes = [];

Error message we get:

Screen Shot 2021-10-25 at 11 27 23 am

I went in to find out why that specific entity object had an issue as this happened when 92% of our documents were already indexed.

Found out my roleTypes were serialised without having the 0 index filled, like:

a:2:{i:1;s:9:"Permanent";i:2;s:10:"Fixed-term";}

As you can see, we have i:1 and i:2 but not i:0 which can happen as this field stores arrays of any sort. To fix it I had to manually change this to a:2:{i:0;s:9:"Permanent";i:1;s:10:"Fixed-term";}

I ran the populate command again and it worked but this definitely felt like a bug.

murilozilli avatar Oct 25 '21 00:10 murilozilli

I am seeing the same thing with version 6.0.0 and a Doctrine json column type.

I have used an array_values() in my getter, to ensure the array returned always has a zero index (for me the index is not important).

benr77 avatar Dec 21 '21 13:12 benr77