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 soham gandhi <so...@gmail.com> on 2018/07/18 04:03:53 UTC

Block Join Faceting issue

Hi,

I am working on a query that must return parent docs and facet on both the
parent and child fields. Here's a sample doc-
<doc>
<field name="id">1</field>
<field name="name">merc</field>
<field name="type">car</field>
<field name="user">sagandhi</field>
<field name="child_id">2</field>
<field name="child_id">3</field>
<field name="doc_type">parent</field>
<doc>
<field name="id">2</field>
<field name="doc_type">child</field>
<field name="class">S</field>
<field name="color">blue</field>
</doc>
<doc>
<field name="id">3</field>
<field name="class">Z</field>
<field name="code">25</field>
<field name="doc_type">child</field>
</doc>
</doc>
I want to search for "merc" or "*" and return facets for type/user from
parent docs, and code/color from child docs. Currently I am not using
blockjoin. Instead I make two queries, one on the parent docs and the other
on the child docs. I get the applicable child_id from the first query and
feed it into the second query to get the child facets.
However this has impacted performance and is not scalable if the child_ids
I get are huge. Is there a way to combine the two queries using block join.
I tried this query -
q=*:* &fq=user:sagandhi &fq={!parent
which="doc_type:parent"}color:blue&facet.field=type&child.facet.field=code

I get this error - Block join faceting is allowed with
ToParentBlockJoinQuery only

Am I missing something here? Any pointers please.

Thanks,
Soham

Re: Block Join Faceting issue

Posted by Mikhail Khludnev <mk...@apache.org>.
 q=*:*&fq={!parent which="doc_type:parent"}+doc_type:child -child_color:*

Make sure that + isn;t grabbed by url encoding.

On Wed, Jul 25, 2018 at 8:23 AM sagandhi <so...@gmail.com> wrote:

> Hi Mikhail,
>
> Thank you for suggesting to use json facet. I tried json.facet, it works
> great and I am able to make a single query instead of two. Now I am
> planning
> to get rid of the duplicate child fields in parent docs. However I ran into
> problems while forming negative queries with block join.
>
> Here's what I would like to query - Get me parent docs whose children do
> not
> have a particular field.
> I tried these but none worked -
>
> q=*:*&fq={!parent which="doc_type:parent"}*-*child_color:*
> q=*:*&fq={!parent which="doc_type:parent" v=$qq}&qq=(!child_color:*)
>
> Currently I have duplicate entries of child fields in parent docs, so I am
> able to do this -
> &fq=!parent_color:*
>
> Is there a way to form this query using block join?
>
> Thanks,
> Soham
>
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>


-- 
Sincerely yours
Mikhail Khludnev

Re: Block Join Faceting issue

Posted by sagandhi <so...@gmail.com>.
Hi Mikhail,

Thank you for suggesting to use json facet. I tried json.facet, it works
great and I am able to make a single query instead of two. Now I am planning
to get rid of the duplicate child fields in parent docs. However I ran into
problems while forming negative queries with block join.

Here's what I would like to query - Get me parent docs whose children do not
have a particular field.
I tried these but none worked - 

q=*:*&fq={!parent which="doc_type:parent"}*-*child_color:*
q=*:*&fq={!parent which="doc_type:parent" v=$qq}&qq=(!child_color:*)

Currently I have duplicate entries of child fields in parent docs, so I am
able to do this - 
&fq=!parent_color:*

Is there a way to form this query using block join? 

Thanks,
Soham




--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: Block Join Faceting issue

Posted by soham gandhi <so...@gmail.com>.
I am using solr 6.2.1. Is json.facet supported there? If not, is there a
way to combine the 2 queries into a single query in solr 6.2.1? In the
example I mentioned, could you please help me form a sample query where I
can facet on both parent as well as child docs?

Thanks,
Soham

On Wed, Jul 18, 2018 at 1:35 PM, Mikhail Khludnev <mk...@apache.org> wrote:

>  child.facet.field  works if parent query goes as q ie q={!parent
> which="doc_type:parent"}color:blue.
> However, it's considered as deprecated and proposed to be replaced with
> json.facet and uniqueBlock
>
> On Wed, Jul 18, 2018 at 7:04 AM soham gandhi <so...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I am working on a query that must return parent docs and facet on both
> the
> > parent and child fields. Here's a sample doc-
> > <doc>
> > <field name="id">1</field>
> > <field name="name">merc</field>
> > <field name="type">car</field>
> > <field name="user">sagandhi</field>
> > <field name="child_id">2</field>
> > <field name="child_id">3</field>
> > <field name="doc_type">parent</field>
> > <doc>
> > <field name="id">2</field>
> > <field name="doc_type">child</field>
> > <field name="class">S</field>
> > <field name="color">blue</field>
> > </doc>
> > <doc>
> > <field name="id">3</field>
> > <field name="class">Z</field>
> > <field name="code">25</field>
> > <field name="doc_type">child</field>
> > </doc>
> > </doc>
> > I want to search for "merc" or "*" and return facets for type/user from
> > parent docs, and code/color from child docs. Currently I am not using
> > blockjoin. Instead I make two queries, one on the parent docs and the
> other
> > on the child docs. I get the applicable child_id from the first query and
> > feed it into the second query to get the child facets.
> > However this has impacted performance and is not scalable if the
> child_ids
> > I get are huge. Is there a way to combine the two queries using block
> join.
> > I tried this query -
> > q=*:* &fq=user:sagandhi &fq={!parent
> > which="doc_type:parent"}color:blue&facet.field=type&child.
> facet.field=code
> >
> > I get this error - Block join faceting is allowed with
> > ToParentBlockJoinQuery only
> >
> > Am I missing something here? Any pointers please.
> >
> > Thanks,
> > Soham
> >
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>

Re: Block Join Faceting issue

Posted by Mikhail Khludnev <mk...@apache.org>.
 child.facet.field  works if parent query goes as q ie q={!parent
which="doc_type:parent"}color:blue.
However, it's considered as deprecated and proposed to be replaced with
json.facet and uniqueBlock

On Wed, Jul 18, 2018 at 7:04 AM soham gandhi <so...@gmail.com>
wrote:

> Hi,
>
> I am working on a query that must return parent docs and facet on both the
> parent and child fields. Here's a sample doc-
> <doc>
> <field name="id">1</field>
> <field name="name">merc</field>
> <field name="type">car</field>
> <field name="user">sagandhi</field>
> <field name="child_id">2</field>
> <field name="child_id">3</field>
> <field name="doc_type">parent</field>
> <doc>
> <field name="id">2</field>
> <field name="doc_type">child</field>
> <field name="class">S</field>
> <field name="color">blue</field>
> </doc>
> <doc>
> <field name="id">3</field>
> <field name="class">Z</field>
> <field name="code">25</field>
> <field name="doc_type">child</field>
> </doc>
> </doc>
> I want to search for "merc" or "*" and return facets for type/user from
> parent docs, and code/color from child docs. Currently I am not using
> blockjoin. Instead I make two queries, one on the parent docs and the other
> on the child docs. I get the applicable child_id from the first query and
> feed it into the second query to get the child facets.
> However this has impacted performance and is not scalable if the child_ids
> I get are huge. Is there a way to combine the two queries using block join.
> I tried this query -
> q=*:* &fq=user:sagandhi &fq={!parent
> which="doc_type:parent"}color:blue&facet.field=type&child.facet.field=code
>
> I get this error - Block join faceting is allowed with
> ToParentBlockJoinQuery only
>
> Am I missing something here? Any pointers please.
>
> Thanks,
> Soham
>


-- 
Sincerely yours
Mikhail Khludnev