I have a Symfony2 project, and I'm trying to implement a search function using Elasticsearch.
My problem: I need to index an entity with optional dedication. This means that my Item object has a parent field that refers to another element.
To perform a search, I want to create filters in this "parent" field. Is my Item.parent NULL? eg.
So, I am using FosElasticaBundle.
Here is my mapping:
types:
Item:
mappings:
name:
children:
type: object
_parent:
type: Item
parent:
type: object
_routing:
required: false
_parent:
type : Item
identifier: id
property : parent
persistence:
...
model_to_elastica_transformer:
service: core.transformer.item
And the transformer does:
$document = new Document();
if (!is_null($item->getParent())) {
$document->setParent($item->getParent()->getId());
} else {
$document->setParent(null);
}
return $document;
And the problem occurs when I try to create my index ( php app/console fos:elastica:populate
)
This command returns the following ResponseException:
index: /traveler/Item caused RoutingMissingException[routing is required for [traveler]/[Item]/[null]]
Do you have an idea why this is not working? And is this a good way to do this?
Thanks,