Thanks Emir. Looks indeed like what I need. On Mon, Jan 15, 2018 at 11:33 AM, Emir Arnautović < emir.arnauto...@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 <max.bridgewa...@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 > >