Reputation: 2056
I'm working with FOS Elastica bundle and trying to index some datas inside Elasticsearch.
I followed the doc so I wrote this conf
fos_elastica:
clients:
default: { host: '%env(ELASTICSEARCH_HOST)%', port: '%env(ELASTICSEARCH_PORT)%' }
indexes:
app:
index_name: app
types:
user:
serializer:
groups: [elastica]
persistence:
driver: orm
model: AppBundle\Entity\User
provider: ~
country:
serializer:
groups: [elastica]
persistence:
driver: orm
model: AppBundle\Entity\Country
provider: ~
Then inside my entities I added the serialization group
use Symfony\Component\Serializer\Annotation\Groups;
...
/**
* @ORM\Table
* @ORM\Entity
*/
class Country
{
...
/**
* @var string
*
* @Groups({"elastica"})
*
* @ORM\Column(type="string", length=64, unique=true)
* @Assert\NotBlank
* @Assert\Length(max=64)
*/
private $name = '';
}
Then when I launch fos:elastica:populate
everything is working well but all the field where I put the elastica
serialization group are not indexed.
I'm using the Symfony serializer and folloewed the official docs but I don't understand and find why I fields are not indexed.
I tried to add
serializer:
serializer: serializer
or
serializer: ~
But I get an error
Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING]
When I try without the serializer, everything is working well and all the defined field are indexed.
Did someone know how to fix this error ? Every issues I found on the FosElastica GitHub repo are related to the JMSSerializer.
Upvotes: 1
Views: 1273
Reputation: 664
Make sure your exclusion strategy is not set to "all". If that is the case, ou should use @JMS\Expose() in order to expose the field to the given groups.
For example :
use JMS\Serializer\Annotation as JMS;
/**
* @JMS\Expose()
* @JMS\Groups(["elastica"})
*/
private $name = '';
Upvotes: 0