I want to fix it in scope of https://issues.apache.org/jira/browse/SOLR-5211 and hope it will be released in 5.5. It will *copy* $UniqueKey into "_root_" aways (regardless of having a child). Thus we will have $UniqueKey really unique. Overriding update will work. But deleteByID won't work out-of-the-box for parents with child. And deleteByQuery should be tweaked to handle blocks. I almost done it in earlier patch. https://issues.apache.org/jira/secure/attachment/12739197/SOLR-7606.patch Is it really urgent for you? I'm asking because there is an easy workaround, despite it seems odd overall.
On Thu, Dec 10, 2015 at 10:41 AM, Bogdan Marinescu < bogdan.marine...@awinta.com> wrote: > Any suggestions about this ? > > > On 12/04/2015 08:26 AM, Bogdan Marinescu wrote: > >> Hi Mikhail, >> >> I would expect the same behaviour as for a database. Meaning if I have a >> field declared as an uniqueKey, then there should only be one document with >> that key, regardless if it has a child or not. >> >> If you add the childless document first and afterwards the child, then >> sol'r should append the child to the already existing document (or rather >> delete the existing one as the new one has newer data). >> >> It's weird because when I query sol'r for that ID, I get two documents >> when I am only expecting one. >> I could do a sort of 'workaround' logic where I would always pick the one >> with children but I think better would be to fix this in sol'r. >> >> Regarding your issue SOLR-5211 < >> https://issues.apache.org/jira/browse/SOLR-5211>. If a document has >> children and you update the parent as childless or in fact delete the >> parent altogether, then the child documents should also be deleted. >> >> I've faced this problem where I was just deleting the parent by id and I >> had lots of orphan documents just laying around. >> >> Regards, >> Bogdan Marinescu >> >> On 12/03/2015 06:26 PM, Mikhail Khludnev wrote: >> >>> Hello Bogdan, >>> You described how it works now. That's how it was implemented. And I can >>> explain why it was done so. >>> >>> Could you please describe the expected behavior for you? >>> >>> Notice, I want to enforce nested (block) behavior always in scope of >>> https://issues.apache.org/jira/browse/SOLR-5211. So, the fields >>> assigned to >>> parent with child and childless single doc will be the same. So, far it's >>> not clear how to amend <uniqueKey> semantic. >>> >>> On Thu, Dec 3, 2015 at 6:35 PM, Bogdan Marinescu < >>> bogdan.marine...@awinta.com> wrote: >>> >>> Hi, >>>> >>>> I have a problem with nested docs. If I create a document with id: 1 and >>>> fieldA:sometext and then add it to sol'r, I get one doc in sol'r. >>>> >>>> Afterwards if I add a child/nested doc to this document I additionally >>>> get >>>> a _root_:1 to the document but the problem is I now have two documents >>>> with >>>> the same ID (id: 1) in sol'r, one with _root_ and the child/nested doc >>>> and >>>> one without it. >>>> >>>> Any ideas why this happens? >>>> Any ideas how to avoid this? >>>> >>>> Thanks, >>>> >>>> >>> >>> >> >> > -- Sincerely yours Mikhail Khludnev Principal Engineer, Grid Dynamics <http://www.griddynamics.com> <mkhlud...@griddynamics.com>