FOSElasticaBundle
FOSElasticaBundle copied to clipboard
Bug with keyword indexing with an array field
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:

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.
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).