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 Florian Fankhauser <f....@littera.eu> on 2018/06/26 13:22:58 UTC
Adding tag to fq makes query return child docs instead of parent docs
Hello,
given the following document structure (books as parent, libraries having these books as children) in a Solr 7.3.1 server:
<update>
<add>
<doc>
<field name="doc_type_s">book</field>
<field name="id">1000</field>
<field name="title_t">Mr. Mercedes</field>
<field name="autor_t">Stephen King</field>
<doc>
<field name="doc_type_s">library</field>
<field name="id">1000/100</field>
<field name="acquisition_date_i">20160810</field>
<field name="city_t">Innsbruck</field>
</doc>
<doc>
<field name="doc_type_s">library</field>
<field name="id">1000/101</field>
<field name="acquisition_date_i">20180103</field>
<field name="city_t">Hall</field>
</doc>
</doc>
<doc>
<field name="doc_type_s">book</field>
<field name="id">1001</field>
<field name="title_t">Noah</field>
<field name="autor_t">Sebastian Fitzek</field>
<doc>
<field name="doc_type_s">library</field>
<field name="id">1001/100</field>
<field name="acquisition_date_i">20170810</field>
<field name="city_t">Innsbruck</field>
</doc>
</doc>
</add>
</update>
Now I want to query with a filter-query on the acquisition_date_i field oft he child-documents and get parent documents as a result:
fq={!parent which=doc_type_s:book} acquisition_date_i:20180626
This works as expected.
Now for some reason I want to exclude the above filter-query from a facet-query. Therefore I need to add a tag to the filter-query:
q={!tag=datefilter}{!parent which=doc_type_s:book} acquisition_date_i:20180626 ....
And now the error occures: Just by adding "{!tag=datefilter}" to the query makes the result now contain child-documents.
I seems like the "{!parent which=doc_type_s:book}" does not work anymore as soon as I add "{!tag=datefilter}" before it.
When I put the "{!tag=datefilter}" after "{!parent which=doc_type_s:book}" then the result is correct again (result contains parent documents) but now the exclude in the facet-query does not work anymore.
So the question is: how can I apply a parent- and a tag-filter to a filter-query?
Thanks for your help.
Florian
AW: Adding tag to fq makes query return child docs instead of parent
docs
Posted by Florian Fankhauser <f....@littera.eu>.
Hi Shawn,
your answer was the solution to the problem!
It worked with the syntax in your example.
Thank you very much, great support!
Florian
-----Ursprüngliche Nachricht-----
Von: Shawn Heisey <ap...@elyograg.org>
Gesendet: Dienstag, 26. Juni 2018 15:35
An: solr-user@lucene.apache.org
Betreff: Re: Adding tag to fq makes query return child docs instead of parent docs
On 6/26/2018 7:22 AM, Florian Fankhauser wrote:
> Now for some reason I want to exclude the above filter-query from a facet-query. Therefore I need to add a tag to the filter-query:
>
> q={!tag=datefilter}{!parent which=doc_type_s:book} acquisition_date_i:20180626 ....
According to the documentation:
https://lucene.apache.org/solr/guide/6_6/local-parameters-in-queries.html#LocalParametersinQueries-BasicSyntaxofLocalParameters
You can't specify multiple localparams like that - it says "You may specify only one local parameters prefix per argument."
I have no idea whether this is going to work, but here's what I would try:
{!parent which=doc_type_s:book tag=datefilter}
If this is not the proper syntax, I hope somebody who actually knows what's possible can speak up and help out.
Thanks,
Shawn
Re: Adding tag to fq makes query return child docs instead of parent
docs
Posted by Shawn Heisey <ap...@elyograg.org>.
On 6/26/2018 7:22 AM, Florian Fankhauser wrote:
> Now for some reason I want to exclude the above filter-query from a facet-query. Therefore I need to add a tag to the filter-query:
>
> q={!tag=datefilter}{!parent which=doc_type_s:book} acquisition_date_i:20180626 ....
According to the documentation:
https://lucene.apache.org/solr/guide/6_6/local-parameters-in-queries.html#LocalParametersinQueries-BasicSyntaxofLocalParameters
You can't specify multiple localparams like that - it says "You may
specify only one local parameters prefix per argument."
I have no idea whether this is going to work, but here's what I would try:
{!parent which=doc_type_s:book tag=datefilter}
If this is not the proper syntax, I hope somebody who actually knows
what's possible can speak up and help out.
Thanks,
Shawn