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 Prathyusha Kondeti <pr...@ceipal.com> on 2018/01/17 12:05:36 UTC

Querying on sum of child documents

Hi,
 I have the following indexed documents
{
   "id":"data1",
   "isParent":"1",
   "_childDocuments":[
      {
         "description":
"Benefit and Payroll consultant with HR team support ",
         "isParent":"2",
         "exp":2
      },
      {
         "description":" ERP Avalon Implementation and Support Payroll",
         "isParent":"2",
         "exp":5
      },
      {
         "description":" lucene solr",
         "isParent":"2",
         "exp":2
      }
   ]

> }



How can I form a query as
*select?q=**:**&fq=(description:Payroll AND sum(exp):[7  TO  10]) AND
**(description:support
AND sum(exp):**[3 TO  10]**) *

and get the parent *document id data1* as response.
I need to sum the experience of child documents only if the description
contains Payroll keyword
Please guide me how can I achive the above query and response with my
indexed documents
-- 

Thanks & Regards,

Prathyusha Kondeti  | Software Engineer

Software Development


[image: website-logo-org.png]

CEIPAL Solutions Pvt Ltd

Prashanthi Towers, 4th Floor, Road No: 92, Jubilee Hills, Hyderabad -
500033, INDIA

[O] +91-40-43515100  [M] +91 9848143513  [E]  prathyusha.k@ceipal.com  [W]
www.ceipal.com

<http://www.ceipal.com>

<http://www.ceipal.com>

[image: consider.png]
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and
delete this e-mail from your system. If you are not the intended recipient
you are notified that disclosing, copying, distributing or taking any
action in reliance on the contents of this information is strictly
prohibited.

Re: Querying on sum of child documents

Posted by Prath <pr...@gmail.com>.
We need  sum of experiences from each child documents. Using this expression
"exp:[4 TO 7]" we are directly querying the single child document with the
experience between 4 to 7 but not sum of experiences of all child
documents.For that we have to do something. Could you please help me out
with that logic.



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

Re: Querying on sum of child documents

Posted by flatmind <fl...@gmail.com>.
Hello Mikhail - Thanks for your help with the query and I was able to get the
result. But when I am trying to add another condition to that, it is not
showing any results, though there are matching records in the index. But
when I execute those queries individually, I am getting the response.

This is the index that we have and it has 2 parent records with few children

 "response":{"numFound":2,"start":0,"docs":[ { "id":"one",
"th_content":["this resume belongs to php developer"], "th_is_parent":1,
"_version_":1626065661717381120, "_childDocuments_":[ { "id":"doc1***one",
"th_recent_exp":["Wokred as java developer"], "th_experience":2,
"th_is_parent":2, "_version_":1626065661717381120}, { "id":"doc2***one",
"th_recent_exp":["experience in java"], "th_experience":2, "th_is_parent":2,
"_version_":1626065661717381120}, { "id":"doc3***one",
"th_recent_exp":["junior software developer"], "th_experience":1,
"th_is_parent":2, "_version_":1626065661717381120}]}, { "id":"two",
"th_content":["this resume belongs to php developer"], "th_is_parent":1,
"_version_":1626065856446332928, "_childDocuments_":[ { "id":"doc1***two",
"th_recent_exp":["Wokred as php developer"], "th_experience":2,
"th_is_parent":2, "_version_":1626065856446332928}, { "id":"doc2***two",
"th_recent_exp":["experience in php"], "th_experience":2, "th_is_parent":2,
"_version_":1626065856446332928}, { "id":"doc3***two",
"th_recent_exp":["junior software developer"], "th_experience":1,
"th_is_parent":2, "_version_":1626065856446332928}]}] }}

When I use the below query either in the Q or FQ, I am able to see 1 record
in the search results. But when I try to add another condition, it is not
giving anything. Please find the below working query and the other one with
one more clause added. Seems that I might be missing a small syntactical
thing that combines both queries to get the results. Appreciate if you could
help here.

*Working Query
=======================*
{!frange l=4}{!parent which=th_is_parent:1 score=total 
v=$chq}&chq=+th_is_parent:2^=0 AND th_recent_exp:php^=0 AND
{!func}th_experience 

*Adding another condition to the above query like below
===========================================*
{!frange l=4}{!parent which=th_is_parent:1 score=total 
v=$chq}&chq=+th_is_parent:2^=0 AND th_recent_exp:*php*^=0 AND
{!func}th_experience *AND* {!frange l=4}{!parent which=th_is_parent:1
score=total 
v=$chq}&chq=+th_is_parent:2^=0 AND th_recent_exp:*java*^=0 AND
{!func}th_experience 

Thank You




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

Re: Querying on sum of child documents

Posted by Mikhail Khludnev <mk...@apache.org>.
q={!frange l=8}{!parent which=isParent:1 score=total
v=$chq}&chq=+isParent:2^=0 AND description:payroll^=0 AND {!func}exp


On Wed, Feb 20, 2019 at 7:39 PM flatmind <fl...@gmail.com> wrote:

> Hi
> I tried with the below query
>
> q={!frange l=8}{!parent which=isParent:1 score=total v=$chq} AND chq=+
> isParent:2 AND description:payroll AND {!func}exp
>
> I applied lower limit as 8 still the record is coming in the results.Where
> sum of the child documents matching with "payroll" description is 7.
> So what's wrong with my function query ?Please help me.
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>


-- 
Sincerely yours
Mikhail Khludnev

Re: Querying on sum of child documents

Posted by flatmind <fl...@gmail.com>.
Hi
I tried with the below query 

q={!frange l=8}{!parent which=isParent:1 score=total v=$chq} AND chq=+ 
isParent:2 AND description:payroll AND {!func}exp

I applied lower limit as 8 still the record is coming in the results.Where
sum of the child documents matching with "payroll" description is 7.
So what's wrong with my function query ?Please help me.



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

Re: Querying on sum of child documents

Posted by Mikhail Khludnev <mk...@apache.org>.
exp=total seems strange it should be score.
Then, childquery  clauses might need to be appended with ^=0 to suppress
unnecessary scoring.
Check debugQuery output to make sure if query is parsed as expected.

On Tue, Jan 30, 2018 at 10:10 AM, Prath <pr...@gmail.com> wrote:

> Hi,
> I used following query
> {!parent which="isParent:1" exp=total}+description:JSON +exp:[4 TO 7]
> {!func}exp.
> It is considering only highest experience from matched descriptions but not
> sum of matched description experience.
> Can you please explain me in detail.
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>



-- 
Sincerely yours
Mikhail Khludnev

Re: Querying on sum of child documents

Posted by Prath <pr...@gmail.com>.
Hi,
I used following query
{!parent which="isParent:1" exp=total}+description:JSON +exp:[4 TO 7]
{!func}exp.
It is considering only highest experience from matched descriptions but not
sum of matched description experience.
Can you please explain me in detail.



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

Re: Querying on sum of child documents

Posted by Mikhail Khludnev <mk...@apache.org>.
Hello,
It should be something like
{!parent ... score=total}+description:support +exp:[3 TO 7] {!func}exp

On Wed, Jan 17, 2018 at 3:05 PM, Prathyusha Kondeti <prathyusha.k@ceipal.com
> wrote:

> Hi,
>  I have the following indexed documents
> {
>    "id":"data1",
>    "isParent":"1",
>    "_childDocuments":[
>       {
>          "description":
> "Benefit and Payroll consultant with HR team support ",
>          "isParent":"2",
>          "exp":2
>       },
>       {
>          "description":" ERP Avalon Implementation and Support Payroll",
>          "isParent":"2",
>          "exp":5
>       },
>       {
>          "description":" lucene solr",
>          "isParent":"2",
>          "exp":2
>       }
>    ]
>
> > }
>
>
>
> How can I form a query as
> *select?q=**:**&fq=(description:Payroll AND sum(exp):[7  TO  10]) AND
> **(description:support
> AND sum(exp):**[3 TO  10]**) *
>
> and get the parent *document id data1* as response.
> I need to sum the experience of child documents only if the description
> contains Payroll keyword
> Please guide me how can I achive the above query and response with my
> indexed documents
> --
>
> Thanks & Regards,
>
> Prathyusha Kondeti  | Software Engineer
>
> Software Development
>
>
> [image: website-logo-org.png]
>
> CEIPAL Solutions Pvt Ltd
>
> Prashanthi Towers, 4th Floor, Road No: 92, Jubilee Hills, Hyderabad -
> 500033, INDIA
>
> [O] +91-40-43515100  [M] +91 9848143513  [E]  prathyusha.k@ceipal.com  [W]
> www.ceipal.com
>
> <http://www.ceipal.com>
>
> <http://www.ceipal.com>
>
> [image: consider.png]
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed.
> If you have received this email in error please notify the system manager.
> This message contains confidential information and is intended only for the
> individual named. If you are not the named addressee you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately by e-mail if you have received this e-mail by mistake and
> delete this e-mail from your system. If you are not the intended recipient
> you are notified that disclosing, copying, distributing or taking any
> action in reliance on the contents of this information is strictly
> prohibited.
>



-- 
Sincerely yours
Mikhail Khludnev