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 Darin Amos <da...@gmail.com> on 2014/12/02 02:35:53 UTC

SOLR Join Query, Use highest weight.

Hello,

I had sent an email a few days ago talking about implementing a custom rollup query component. I have changed directions a little bit because I have learned about the JoinQuery.

I have an index that contains a combination of parent and child documents. The parent child relationship is always one-to-many.

Here is a very simple sample query:

http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child <http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child>

When I have a more specific query that actually give some meaningful weights: <  q=name:(*Shirt*)%20OR%20name:(*Small*)  >, it appears the rollup query assigns a weight to the parent of the last document encountered. For example, if a parents 2 children has weights of 1.4 and 0.4 without the join query, the parent has a weight of 0.4 after the join query.

Is there a way that I can extend or modify the join query so it would assign the highest child weight to the parent document?

Thanks!!

Darin

Re: SOLR Join Query, Use highest weight.

Posted by Michael Sokolov <ms...@safaribooksonline.com>.
We simply index parent and child documents with the same field value, 
and group on that, querying both parent and child documents. If you 
boost the parent it will show up as the first result in the group.  Then 
you get all related documents together. in the same group.

-Mike

On 12/02/2014 02:27 PM, Darin Amos wrote:
> Hi,
>
> Thanks for the response, I have considered grouping often, but grouping does not return the parent document, just the group id. I would still have to add something to take the group id’s and get the parent documents.
>
> Thanks
>
> Darin
>
>> On Dec 2, 2014, at 2:11 PM, Michael Sokolov <ms...@safaribooksonline.com> wrote:
>>
>> Have you considered using grouping?  If I understand your requirements, I think it does what you want.
>>
>> https://cwiki.apache.org/confluence/display/solr/Result+Grouping <https://cwiki.apache.org/confluence/display/solr/Result+Grouping>
>>
>> On 12/02/2014 12:59 PM, Darin Amos wrote:
>>> Thanks!
>>>
>>> I will take a look at this. I do have an additional question, since after a bunch of digging I believe I am going to run into another dead end.
>>>
>>> I want to execute the join (or rollup) query, but I want the facets to represent the facets of all the child documents, not the resulting product documents. From what I gather, this is not possible.
>>>
>>> My thought process of what I want to get goes as follows:
>>>
>>> 1) Execute my search for children
>>> 2) Get the facets for all the children
>>> 3) Rollup the child dataset into its parent dataset, keeping the score.
>>>
>>> Is this easily possible with the tools available today?
>>>
>>> Thanks!
>>>
>>> Darin
>>>
>>>
>>>
>>>> On Dec 1, 2014, at 11:01 PM, Mikhail Khludnev <mk...@griddynamics.com> wrote:
>>>>
>>>> Hello,
>>>>
>>>> AFAIK {!join} doesn't supply any meaningful scores.
>>>> I can suggest https://issues.apache.org/jira/browse/SOLR-6234 <https://issues.apache.org/jira/browse/SOLR-6234> <https://issues.apache.org/jira/browse/SOLR-6234 <https://issues.apache.org/jira/browse/SOLR-6234>>
>>>>
>>>> On Tue, Dec 2, 2014 at 4:35 AM, Darin Amos <darincs@gmail.com <ma...@gmail.com> <mailto:darincs@gmail.com <ma...@gmail.com>>> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I had sent an email a few days ago talking about implementing a custom
>>>>> rollup query component. I have changed directions a little bit because I
>>>>> have learned about the JoinQuery.
>>>>>
>>>>> I have an index that contains a combination of parent and child documents.
>>>>> The parent child relationship is always one-to-many.
>>>>>
>>>>> Here is a very simple sample query:
>>>>>
>>>>>
>>>>> http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child <http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child>
>>>>> <
>>>>> http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child <http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child><http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child <http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child>>
>>>>> When I have a more specific query that actually give some meaningful
>>>>> weights: <  q=name:(*Shirt*)%20OR%20name:(*Small*)  >, it appears the
>>>>> rollup query assigns a weight to the parent of the last document
>>>>> encountered. For example, if a parents 2 children has weights of 1.4 and
>>>>> 0.4 without the join query, the parent has a weight of 0.4 after the join
>>>>> query.
>>>>>
>>>>> Is there a way that I can extend or modify the join query so it would
>>>>> assign the highest child weight to the parent document?
>>>>>
>>>>> Thanks!!
>>>>>
>>>>> Darin
>>>>
>>>>
>>>> -- 
>>>> Sincerely yours
>>>> Mikhail Khludnev
>>>> Principal Engineer,
>>>> Grid Dynamics
>>>>
>>>> <http://www.griddynamics.com <http://www.griddynamics.com/> <http://www.griddynamics.com/ <http://www.griddynamics.com/>>>
>>>> <mkhludnev@griddynamics.com <ma...@griddynamics.com> <mailto:mkhludnev@griddynamics.com <ma...@griddynamics.com>>>
>


Re: SOLR Join Query, Use highest weight.

Posted by Darin Amos <da...@gmail.com>.
Hi,

Thanks for the response, I have considered grouping often, but grouping does not return the parent document, just the group id. I would still have to add something to take the group id’s and get the parent documents.

Thanks

Darin

> On Dec 2, 2014, at 2:11 PM, Michael Sokolov <ms...@safaribooksonline.com> wrote:
> 
> Have you considered using grouping?  If I understand your requirements, I think it does what you want.
> 
> https://cwiki.apache.org/confluence/display/solr/Result+Grouping <https://cwiki.apache.org/confluence/display/solr/Result+Grouping>
> 
> On 12/02/2014 12:59 PM, Darin Amos wrote:
>> Thanks!
>> 
>> I will take a look at this. I do have an additional question, since after a bunch of digging I believe I am going to run into another dead end.
>> 
>> I want to execute the join (or rollup) query, but I want the facets to represent the facets of all the child documents, not the resulting product documents. From what I gather, this is not possible.
>> 
>> My thought process of what I want to get goes as follows:
>> 
>> 1) Execute my search for children
>> 2) Get the facets for all the children
>> 3) Rollup the child dataset into its parent dataset, keeping the score.
>> 
>> Is this easily possible with the tools available today?
>> 
>> Thanks!
>> 
>> Darin
>> 
>> 
>> 
>>> On Dec 1, 2014, at 11:01 PM, Mikhail Khludnev <mk...@griddynamics.com> wrote:
>>> 
>>> Hello,
>>> 
>>> AFAIK {!join} doesn't supply any meaningful scores.
>>> I can suggest https://issues.apache.org/jira/browse/SOLR-6234 <https://issues.apache.org/jira/browse/SOLR-6234> <https://issues.apache.org/jira/browse/SOLR-6234 <https://issues.apache.org/jira/browse/SOLR-6234>>
>>> 
>>> On Tue, Dec 2, 2014 at 4:35 AM, Darin Amos <darincs@gmail.com <ma...@gmail.com> <mailto:darincs@gmail.com <ma...@gmail.com>>> wrote:
>>> 
>>>> Hello,
>>>> 
>>>> I had sent an email a few days ago talking about implementing a custom
>>>> rollup query component. I have changed directions a little bit because I
>>>> have learned about the JoinQuery.
>>>> 
>>>> I have an index that contains a combination of parent and child documents.
>>>> The parent child relationship is always one-to-many.
>>>> 
>>>> Here is a very simple sample query:
>>>> 
>>>> 
>>>> http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child <http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child>
>>>> <
>>>> http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child <http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child><http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child <http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child>>
>>>> When I have a more specific query that actually give some meaningful
>>>> weights: <  q=name:(*Shirt*)%20OR%20name:(*Small*)  >, it appears the
>>>> rollup query assigns a weight to the parent of the last document
>>>> encountered. For example, if a parents 2 children has weights of 1.4 and
>>>> 0.4 without the join query, the parent has a weight of 0.4 after the join
>>>> query.
>>>> 
>>>> Is there a way that I can extend or modify the join query so it would
>>>> assign the highest child weight to the parent document?
>>>> 
>>>> Thanks!!
>>>> 
>>>> Darin
>>> 
>>> 
>>> 
>>> -- 
>>> Sincerely yours
>>> Mikhail Khludnev
>>> Principal Engineer,
>>> Grid Dynamics
>>> 
>>> <http://www.griddynamics.com <http://www.griddynamics.com/> <http://www.griddynamics.com/ <http://www.griddynamics.com/>>>
>>> <mkhludnev@griddynamics.com <ma...@griddynamics.com> <mailto:mkhludnev@griddynamics.com <ma...@griddynamics.com>>>


Re: SOLR Join Query, Use highest weight.

Posted by Michael Sokolov <ms...@safaribooksonline.com>.
Have you considered using grouping?  If I understand your requirements, 
I think it does what you want.

https://cwiki.apache.org/confluence/display/solr/Result+Grouping

On 12/02/2014 12:59 PM, Darin Amos wrote:
> Thanks!
>
> I will take a look at this. I do have an additional question, since after a bunch of digging I believe I am going to run into another dead end.
>
> I want to execute the join (or rollup) query, but I want the facets to represent the facets of all the child documents, not the resulting product documents. From what I gather, this is not possible.
>
> My thought process of what I want to get goes as follows:
>
> 1) Execute my search for children
> 2) Get the facets for all the children
> 3) Rollup the child dataset into its parent dataset, keeping the score.
>
> Is this easily possible with the tools available today?
>
> Thanks!
>
> Darin
>
>
>
>> On Dec 1, 2014, at 11:01 PM, Mikhail Khludnev <mk...@griddynamics.com> wrote:
>>
>> Hello,
>>
>> AFAIK {!join} doesn't supply any meaningful scores.
>> I can suggest https://issues.apache.org/jira/browse/SOLR-6234 <https://issues.apache.org/jira/browse/SOLR-6234>
>>
>> On Tue, Dec 2, 2014 at 4:35 AM, Darin Amos <darincs@gmail.com <ma...@gmail.com>> wrote:
>>
>>> Hello,
>>>
>>> I had sent an email a few days ago talking about implementing a custom
>>> rollup query component. I have changed directions a little bit because I
>>> have learned about the JoinQuery.
>>>
>>> I have an index that contains a combination of parent and child documents.
>>> The parent child relationship is always one-to-many.
>>>
>>> Here is a very simple sample query:
>>>
>>>
>>> http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child
>>> <
>>> http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child <http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child>
>>> When I have a more specific query that actually give some meaningful
>>> weights: <  q=name:(*Shirt*)%20OR%20name:(*Small*)  >, it appears the
>>> rollup query assigns a weight to the parent of the last document
>>> encountered. For example, if a parents 2 children has weights of 1.4 and
>>> 0.4 without the join query, the parent has a weight of 0.4 after the join
>>> query.
>>>
>>> Is there a way that I can extend or modify the join query so it would
>>> assign the highest child weight to the parent document?
>>>
>>> Thanks!!
>>>
>>> Darin
>>
>>
>>
>> -- 
>> Sincerely yours
>> Mikhail Khludnev
>> Principal Engineer,
>> Grid Dynamics
>>
>> <http://www.griddynamics.com <http://www.griddynamics.com/>>
>> <mkhludnev@griddynamics.com <ma...@griddynamics.com>>
>


Re: SOLR Join Query, Use highest weight.

Posted by Darin Amos <da...@gmail.com>.
Thanks!

I will take a look at this. I do have an additional question, since after a bunch of digging I believe I am going to run into another dead end.

I want to execute the join (or rollup) query, but I want the facets to represent the facets of all the child documents, not the resulting product documents. From what I gather, this is not possible.

My thought process of what I want to get goes as follows:

1) Execute my search for children
2) Get the facets for all the children
3) Rollup the child dataset into its parent dataset, keeping the score.

Is this easily possible with the tools available today?

Thanks!

Darin



> On Dec 1, 2014, at 11:01 PM, Mikhail Khludnev <mk...@griddynamics.com> wrote:
> 
> Hello,
> 
> AFAIK {!join} doesn't supply any meaningful scores.
> I can suggest https://issues.apache.org/jira/browse/SOLR-6234 <https://issues.apache.org/jira/browse/SOLR-6234>
> 
> On Tue, Dec 2, 2014 at 4:35 AM, Darin Amos <darincs@gmail.com <ma...@gmail.com>> wrote:
> 
>> Hello,
>> 
>> I had sent an email a few days ago talking about implementing a custom
>> rollup query component. I have changed directions a little bit because I
>> have learned about the JoinQuery.
>> 
>> I have an index that contains a combination of parent and child documents.
>> The parent child relationship is always one-to-many.
>> 
>> Here is a very simple sample query:
>> 
>> 
>> http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child
>> <
>> http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child <http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child>
>>> 
>> 
>> When I have a more specific query that actually give some meaningful
>> weights: <  q=name:(*Shirt*)%20OR%20name:(*Small*)  >, it appears the
>> rollup query assigns a weight to the parent of the last document
>> encountered. For example, if a parents 2 children has weights of 1.4 and
>> 0.4 without the join query, the parent has a weight of 0.4 after the join
>> query.
>> 
>> Is there a way that I can extend or modify the join query so it would
>> assign the highest child weight to the parent document?
>> 
>> Thanks!!
>> 
>> Darin
> 
> 
> 
> 
> -- 
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
> 
> <http://www.griddynamics.com <http://www.griddynamics.com/>>
> <mkhludnev@griddynamics.com <ma...@griddynamics.com>>


Re: SOLR Join Query, Use highest weight.

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Hello,

AFAIK {!join} doesn't supply any meaningful scores.
I can suggest https://issues.apache.org/jira/browse/SOLR-6234

On Tue, Dec 2, 2014 at 4:35 AM, Darin Amos <da...@gmail.com> wrote:

> Hello,
>
> I had sent an email a few days ago talking about implementing a custom
> rollup query component. I have changed directions a little bit because I
> have learned about the JoinQuery.
>
> I have an index that contains a combination of parent and child documents.
> The parent child relationship is always one-to-many.
>
> Here is a very simple sample query:
>
>
> http://localhost:8983/solr/testcore/select?q=*:*&fq={!join%20from=parent%20to=id}type:child
> <
> http://localhost:8983/solr/testcore/select?q=*:*&fq=%7B!join%20from=parent%20to=id%7Dtype:child
> >
>
> When I have a more specific query that actually give some meaningful
> weights: <  q=name:(*Shirt*)%20OR%20name:(*Small*)  >, it appears the
> rollup query assigns a weight to the parent of the last document
> encountered. For example, if a parents 2 children has weights of 1.4 and
> 0.4 without the join query, the parent has a weight of 0.4 after the join
> query.
>
> Is there a way that I can extend or modify the join query so it would
> assign the highest child weight to the parent document?
>
> Thanks!!
>
> Darin




-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mk...@griddynamics.com>