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 Max Bridgewater <ma...@gmail.com> on 2018/01/15 16:27:49 UTC

Parallelizing queries without Custom Component

Hi,

My index is composed of product reviews. Each review contains the id of the
product it refers to. But it also contains a rating for this product and
the number of negative feedback provided on this product.

{
   id: solr doc id,
   rating: number between 0 and 5,
   product_id: the product that is being reviewed,
   negative_feedback: how many negative feedbacks on this product
}

The query below returns the "worst" review for the given product  7453632.
Worst is defined as  rated 1 to 3 and having the highest number of negative
feedback.

/select?q=product_id:7453632&fq=rating:[1 TO 3]&sort=negative_feedback
desc&rows=1

The query works as intended. Now the challenging part is to extend this
query to support many product_id. If executed with many product Id, the
result should be the list of worst reviews for all the provided products.

A query of the following form would return the list of worst products for
products: 7453632,645454,534664.

/select?q=product_id:[7453632,645454,534664]&fq=rating:[1 TO
3]&sort=negative_feedback desc

Is there a way to do this in Solr without custom component?

Thanks.
Max

Re: Parallelizing queries without Custom Component

Posted by Max Bridgewater <ma...@gmail.com>.
Thanks Emir. Looks indeed like what I need.

On Mon, Jan 15, 2018 at 11:33 AM, Emir Arnautović <
emir.arnautovic@sematext.com> wrote:

> Hi Max,
> It seems to me that you are looking for grouping
> https://lucene.apache.org/solr/guide/6_6/result-grouping.html <
> https://lucene.apache.org/solr/guide/6_6/result-grouping.html> or field
> collapsing https://lucene.apache.org/solr/guide/6_6/collapse-and-
> expand-results.html <https://lucene.apache.org/
> solr/guide/6_6/collapse-and-expand-results.html> feature.
>
> HTH,
> Emir
> --
> Monitoring - Log Management - Alerting - Anomaly Detection
> Solr & Elasticsearch Consulting Support Training - http://sematext.com/
>
>
>
> > On 15 Jan 2018, at 17:27, Max Bridgewater <ma...@gmail.com>
> wrote:
> >
> > Hi,
> >
> > My index is composed of product reviews. Each review contains the id of
> the
> > product it refers to. But it also contains a rating for this product and
> > the number of negative feedback provided on this product.
> >
> > {
> >   id: solr doc id,
> >   rating: number between 0 and 5,
> >   product_id: the product that is being reviewed,
> >   negative_feedback: how many negative feedbacks on this product
> > }
> >
> > The query below returns the "worst" review for the given product
> 7453632.
> > Worst is defined as  rated 1 to 3 and having the highest number of
> negative
> > feedback.
> >
> > /select?q=product_id:7453632&fq=rating:[1 TO 3]&sort=negative_feedback
> > desc&rows=1
> >
> > The query works as intended. Now the challenging part is to extend this
> > query to support many product_id. If executed with many product Id, the
> > result should be the list of worst reviews for all the provided products.
> >
> > A query of the following form would return the list of worst products for
> > products: 7453632,645454,534664.
> >
> > /select?q=product_id:[7453632,645454,534664]&fq=rating:[1 TO
> > 3]&sort=negative_feedback desc
> >
> > Is there a way to do this in Solr without custom component?
> >
> > Thanks.
> > Max
>
>

Re: Parallelizing queries without Custom Component

Posted by Emir Arnautović <em...@sematext.com>.
Hi Max,
It seems to me that you are looking for grouping https://lucene.apache.org/solr/guide/6_6/result-grouping.html <https://lucene.apache.org/solr/guide/6_6/result-grouping.html> or field collapsing https://lucene.apache.org/solr/guide/6_6/collapse-and-expand-results.html <https://lucene.apache.org/solr/guide/6_6/collapse-and-expand-results.html> feature.

HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/



> On 15 Jan 2018, at 17:27, Max Bridgewater <ma...@gmail.com> wrote:
> 
> Hi,
> 
> My index is composed of product reviews. Each review contains the id of the
> product it refers to. But it also contains a rating for this product and
> the number of negative feedback provided on this product.
> 
> {
>   id: solr doc id,
>   rating: number between 0 and 5,
>   product_id: the product that is being reviewed,
>   negative_feedback: how many negative feedbacks on this product
> }
> 
> The query below returns the "worst" review for the given product  7453632.
> Worst is defined as  rated 1 to 3 and having the highest number of negative
> feedback.
> 
> /select?q=product_id:7453632&fq=rating:[1 TO 3]&sort=negative_feedback
> desc&rows=1
> 
> The query works as intended. Now the challenging part is to extend this
> query to support many product_id. If executed with many product Id, the
> result should be the list of worst reviews for all the provided products.
> 
> A query of the following form would return the list of worst products for
> products: 7453632,645454,534664.
> 
> /select?q=product_id:[7453632,645454,534664]&fq=rating:[1 TO
> 3]&sort=negative_feedback desc
> 
> Is there a way to do this in Solr without custom component?
> 
> Thanks.
> Max


Re: Parallelizing queries without Custom Component

Posted by Mikhail Khludnev <mk...@apache.org>.
It's also can be done with {!join .. score=max}... but this join is usually
slow on big indices.

On Mon, Jan 15, 2018 at 7:27 PM, Max Bridgewater <ma...@gmail.com>
wrote:

> Hi,
>
> My index is composed of product reviews. Each review contains the id of the
> product it refers to. But it also contains a rating for this product and
> the number of negative feedback provided on this product.
>
> {
>    id: solr doc id,
>    rating: number between 0 and 5,
>    product_id: the product that is being reviewed,
>    negative_feedback: how many negative feedbacks on this product
> }
>
> The query below returns the "worst" review for the given product  7453632.
> Worst is defined as  rated 1 to 3 and having the highest number of negative
> feedback.
>
> /select?q=product_id:7453632&fq=rating:[1 TO 3]&sort=negative_feedback
> desc&rows=1
>
> The query works as intended. Now the challenging part is to extend this
> query to support many product_id. If executed with many product Id, the
> result should be the list of worst reviews for all the provided products.
>
> A query of the following form would return the list of worst products for
> products: 7453632,645454,534664.
>
> /select?q=product_id:[7453632,645454,534664]&fq=rating:[1 TO
> 3]&sort=negative_feedback desc
>
> Is there a way to do this in Solr without custom component?
>
> Thanks.
> Max
>



-- 
Sincerely yours
Mikhail Khludnev