Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

RoutingMissingException[routing is required for [search]/[images]/[86]] #93

Closed
pdrosos opened this issue Aug 5, 2014 · 4 comments
Closed

Comments

@pdrosos
Copy link

pdrosos commented Aug 5, 2014

Hello,

I am using this library for persisting Doctrine entities in Elasticsearch using Doctrine life cycle events. I have two types: images and photographers. Photographers are set as parent of images. Here are their mappings:

{
    "my_search" : {
        "mappings" : {
            "photographers" : {
                "properties" : {
                    "fullName" : {
                        "type" : "string",
                        "include_in_all" : true
                    }
                }
            },
            "images" : {
                "_parent" : {
                    "type" : "photographers"
                },
                "_routing" : {
                    "required" : true
                },
                "properties" : {
                    "description" : {
                        "type" : "string",
                        "include_in_all" : true
                    },
                    "headline" : {
                        "type" : "string",
                        "include_in_all" : true
                    }
                }
            }
        }
    }
}

On image postPersist/postUpdate this exception is thrown:

Elastica\Exception\ResponseException
File:
    /var/www/search/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php:146
Message:
    RoutingMissingException[routing is required for [my_search]/[images]/[86]]

I use the same annotations like the entities in the demo folder of the library. The demo works fine, but my code doesn't.

Can someone give me a hint what could be the problem? Any help will be appreciated!
Thanks in advance.

@MrHash
Copy link
Contributor

MrHash commented Aug 5, 2014

Are you setting the parent value on the images? In the demo it uses $this->setParent($user->getId())

@MrHash
Copy link
Contributor

MrHash commented Aug 5, 2014

The other thing to watch out for is that if the parent object does not have an id value the routing will fail.

@pdrosos
Copy link
Author

pdrosos commented Aug 5, 2014

Thank you for you reply!

It works now, it seems that the field, which contains the parent id in the Images entity must have exactly the name $_parent. it was $photographer before and it didn't work.

@MrHash
Copy link
Contributor

MrHash commented Aug 5, 2014

OK there is a way you can use the annotation attribute as @MAP\Parameter(name="_parent") if you want and then you should be able to use any member name.

@MrHash MrHash closed this as completed Aug 5, 2014
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants