You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Alexandre Rafalovitch <ar...@gmail.com> on 2016/09/04 02:51:05 UTC

Nested documents: deleting the whole subtree

Hello,

If I am correct, deleting parent document still keeps the child
documents in the index. Which means they now have dangling _root_
references and what not.

What's the easiest delete command to take out the parent and all its
multilevel children, when I find the parents themselves with a query?

So far, I got:
(+type:release +release_name:"6.1.0") {!child
of=type:release}release_name:"6.1.0"

Is there a better way I missed?

Regards,
   Alex.
P.s. Interestingly, the above query will still match children after
the parent record is still gone. Until the merge/optimize anyway.
Which shows that the deleted record filtering happens after all the
matching, not just parent's matching.

----
Newsletter and resources for Solr beginners and intermediates:
http://www.solr-start.com/

Re: Nested documents: deleting the whole subtree

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
 I can get this to:

"q":"(+${parent_match} +${condition_match}) {!child
of=${parent_match}}${condition_match}",

"parent_match":"type:release",

"condition_match":"release_name:\"6.1.0\"",

But I am not sure that's "smarter".

Regards,
   Alex.
----
Newsletter and resources for Solr beginners and intermediates:
http://www.solr-start.com/


On 4 September 2016 at 13:16, Alexandre Rafalovitch <ar...@gmail.com> wrote:
> Right.
>
> But how do I structure the query to say to match all root values that
> correspond to the parent entries selected by query.
>
> Maybe I am just blanking here but how do I form the query:
> q=_root_:[set of id values from query (+type:release +release_name:"6.1.0")]
>
> Regards,
>    Alex.
>
> ----
> Newsletter and resources for Solr beginners and intermediates:
> http://www.solr-start.com/
>
>
> On 4 September 2016 at 12:43, Mikhail Khludnev <mk...@apache.org> wrote:
>> Hello Alex,
>> Internally, _root_ field is assigned across whole block. You can use it in
>> deleteByQuery. The value for this field is equal to parent's uniqueKey.
>>
>> On Sun, Sep 4, 2016 at 5:51 AM, Alexandre Rafalovitch <ar...@gmail.com>
>> wrote:
>>
>>> Hello,
>>>
>>> If I am correct, deleting parent document still keeps the child
>>> documents in the index. Which means they now have dangling _root_
>>> references and what not.
>>>
>>> What's the easiest delete command to take out the parent and all its
>>> multilevel children, when I find the parents themselves with a query?
>>>
>>> So far, I got:
>>> (+type:release +release_name:"6.1.0") {!child
>>> of=type:release}release_name:"6.1.0"
>>>
>>> Is there a better way I missed?
>>>
>>> Regards,
>>>    Alex.
>>> P.s. Interestingly, the above query will still match children after
>>> the parent record is still gone. Until the merge/optimize anyway.
>>> Which shows that the deleted record filtering happens after all the
>>> matching, not just parent's matching.
>>>
>>> ----
>>> Newsletter and resources for Solr beginners and intermediates:
>>> http://www.solr-start.com/
>>>
>>
>>
>>
>> --
>> Sincerely yours
>> Mikhail Khludnev

Re: Nested documents: deleting the whole subtree

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Right.

But how do I structure the query to say to match all root values that
correspond to the parent entries selected by query.

Maybe I am just blanking here but how do I form the query:
q=_root_:[set of id values from query (+type:release +release_name:"6.1.0")]

Regards,
   Alex.

----
Newsletter and resources for Solr beginners and intermediates:
http://www.solr-start.com/


On 4 September 2016 at 12:43, Mikhail Khludnev <mk...@apache.org> wrote:
> Hello Alex,
> Internally, _root_ field is assigned across whole block. You can use it in
> deleteByQuery. The value for this field is equal to parent's uniqueKey.
>
> On Sun, Sep 4, 2016 at 5:51 AM, Alexandre Rafalovitch <ar...@gmail.com>
> wrote:
>
>> Hello,
>>
>> If I am correct, deleting parent document still keeps the child
>> documents in the index. Which means they now have dangling _root_
>> references and what not.
>>
>> What's the easiest delete command to take out the parent and all its
>> multilevel children, when I find the parents themselves with a query?
>>
>> So far, I got:
>> (+type:release +release_name:"6.1.0") {!child
>> of=type:release}release_name:"6.1.0"
>>
>> Is there a better way I missed?
>>
>> Regards,
>>    Alex.
>> P.s. Interestingly, the above query will still match children after
>> the parent record is still gone. Until the merge/optimize anyway.
>> Which shows that the deleted record filtering happens after all the
>> matching, not just parent's matching.
>>
>> ----
>> Newsletter and resources for Solr beginners and intermediates:
>> http://www.solr-start.com/
>>
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev

Re: Nested documents: deleting the whole subtree

Posted by Mikhail Khludnev <mk...@apache.org>.
Hello Alex,
Internally, _root_ field is assigned across whole block. You can use it in
deleteByQuery. The value for this field is equal to parent's uniqueKey.

On Sun, Sep 4, 2016 at 5:51 AM, Alexandre Rafalovitch <ar...@gmail.com>
wrote:

> Hello,
>
> If I am correct, deleting parent document still keeps the child
> documents in the index. Which means they now have dangling _root_
> references and what not.
>
> What's the easiest delete command to take out the parent and all its
> multilevel children, when I find the parents themselves with a query?
>
> So far, I got:
> (+type:release +release_name:"6.1.0") {!child
> of=type:release}release_name:"6.1.0"
>
> Is there a better way I missed?
>
> Regards,
>    Alex.
> P.s. Interestingly, the above query will still match children after
> the parent record is still gone. Until the merge/optimize anyway.
> Which shows that the deleted record filtering happens after all the
> matching, not just parent's matching.
>
> ----
> Newsletter and resources for Solr beginners and intermediates:
> http://www.solr-start.com/
>



-- 
Sincerely yours
Mikhail Khludnev