-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add a child document to a parent document #35
Comments
Yeah, parent/child isn't very well supported by Sherlock right now. I think you can fake it by doing this: $doc = $sherlock->document()->index('shares')
->type('comment')
->document(array("text" => "test comment"), "1?parent=2"); Internally, the ID parameter of a document is simply appended to the URI, so this little hack should work until proper functionality is built (probably while the whole indexing class is refactored, see #34 ) Sorry =( |
Could be useful when indexing pages. When a page is set offline, it's deleted from the index, but I also need its children to be removed from the index. Trying to figure out how best to do this. |
I tried using the "1?parent=2" but then my delete request wouldn't find my document anymore, when I remove the parent parameter, it finds the document. So somehow when you define a parent, the document won't be found by id. |
Did you replace the 1 with the ID of your new document? On Tue, Apr 16, 2013 at 6:12 AM, Kenny Debrauwer [email protected]
|
Yes, I checked my index with the head plugin and the document ID's were identical |
Hm, the parent field is definitely necessary for child deletions. Without the parent field, the ID is used as the hash and the delete request could be sent to the incorrect shard. It's either a syntax problem with the generated JSON (can you get a debug print out of the request URI?), or potentially a problem with your parent/child mapping. |
At the moment I created my own parent/ancestors field and worked with that to find and delete child documents. See method starting from line 202 here : https://github.com/Kunstmaan/KunstmaanNodeSearchBundle/blob/master/Configuration/NodeSearchConfiguration.php I'll give it another go like suggested above and I'll post my findings here. |
Ah, I see. That may be the best solution for the time being, I deliberately left parent/child support in a spotty condition because I wanted to fill out the core functionality first (same reason nested and geo support is pretty poor across the library). |
I can't figure out how to add a child document, as in one defined with a _parent mapping
Manually I would do:
The text was updated successfully, but these errors were encountered: