Hi Mikhail,

thanks for the answer, although both of queries still are giving me the
same "*child query must only match non-parent docs*" IllegalState error, as
I understand it is still seeing the second clause (has_schedules:false) as
part of the child filter.

Even using the v parameter inside the {!parent} part is not recognising the
second clause.


Anyway, finally the nested queries have been a solution for me. Using the
following filter query has made the desired behaviour:

_query_:"{!parent which='content_type:activity'}(schedule.weekday:1 OR
schedule.weekday:2)" OR _query_:"has_new_filters:false"

Any thoughts on this kind of nested queries (_query_) performance?

Best regards,
Ivan

2017-01-19 18:40 GMT+01:00 Mikhail Khludnev <m...@apache.org>:

> It's my pet peeve. Try
> ?q={!parent which=content_type:activity}(schedule.weekday:1) OR
> has_schedules:false&debugQuery=true
> vs
> ?q= {!parent which=content_type:activity}(schedule.weekday:1) OR
> has_schedules:false&debugQuery=true
> and you'll see how space matters.
> The pro's way is to
>
> ?q={!parent which=content_type:activity v=$childq} has_schedules:false
> &debugQuery=true&childq=schedule.weekday:1
>
> Also check this, it deserves.
>
> https://lucidworks.com/blog/2009/03/31/nested-queries-in-solr/Why Not AND,
> OR, And NOT? | Lucidworks.com
> <https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=
> web&cd=1&cad=rja&uact=8&ved=0ahUKEwjF34DJ387RAhWKKcAKHQiFC
> DAQFggmMAA&url=https%3A%2F%2Flucidworks.com%2Fblog%
> 2F2011%2F12%2F28%2Fwhy-not-and-or-and-not%2F&usg=
> AFQjCNH5ilVhXIevavTAURQuLzTZORbTvQ&bvm=bv.144224172,d.bGs>
> http://blog-archive.griddynamics.com/2013/12/grandchildren-and-siblings-
> with-block.html
>
>
> On Thu, Jan 19, 2017 at 7:33 PM, Ivan Bianchi <i...@wikiloc.com> wrote:
>
> > I hope someone can help me because I have spent too many time looking for
> > this issue :(
> >
> > I have 2 kind of documents related with an 1-n relation, in my example
> this
> > is 1 activity has many schedules.
> > To achieve this I have some inner child document with schedule fields
> > inside the activity document. The identifier field of the document is
> > called content_type.
> >
> > In the activity I have a boolean field to detect if the document has
> > children (schedules) called 'has_schedules'.
> >
> > I'm trying to find the documents whose children have a weekday = 1 OR
> they
> > don't have children. Here's the filter query:
> > "{!parent which=content_type:activity}(schedule.weekday:1)" OR
> > has_schedules:false
> >
> > I don't understand how the " char works in here, wherever I enclose the
> > condition with " char, Solr ignores it. For example the previous query is
> > equal to has_schedules:false, on the contrary I only get the first
> > condition. Also, if I use the "(" it gives me a syntax error.
> > The other issue here, is that if I remove the " chars, Solr gets the
> second
> > condition (has_schedules:false) as part of the nested child query, which
> > implies an error as this is a parent's field.
> >
> > Thank you for any help,
> >
> >
> > --
> > Ivan
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>



-- 
Ivan

Reply via email to