Re: Solr returns incorrect results after sorting
Then you just have to remove the group.sort especially if your group limit is set to 1. Le 19 mars 2015 16:57, kumarraj rajitpro2...@gmail.com a écrit : *if the number of documents in one group is more than one then you cannot ensure that this document reflects the main sort Is there a way the top record which is coming up in the group is considered for sorting? We require to show the record from 212(even though price is low) in both the cases of high to low or low to high..and still the main sorting should work? -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266p4194008.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr returns incorrect results after sorting
*if the number of documents in one group is more than one then you cannot ensure that this document reflects the main sort Is there a way the top record which is coming up in the group is considered for sorting? We require to show the record from 212(even though price is low) in both the cases of high to low or low to high..and still the main sorting should work? -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266p4194008.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr returns incorrect results after sorting
Hi Raj, The group.sort you are using defines multiple criterias. The first criteria is the big solr function starting with the max. This means that inside each group the documents will be sorted by this criteria and if the values are equals between two documents then the comparison fallbacks to the second criteria (inStock_boolean desc) and so on. *Even though if i add price asc in the group.sort, but still the main sort does not consider that.* The main sort does not have to consider what's in the group.sort. The group.sort defines the way the documents are sorted inside each group. So if you want to sort the document inside each group with the same order than in the main sort you can remove the group.sort or you can have a primary sort on pricecommon_double desc in your group.sort: *group.sort=pricecommon_double desc, max(if(exists(query({!v='storeName_string:212'})),2,0),if(exists(query({!v='storeName_string:203'})),1,0)) desc,inStock_boolean desc,geodist() asc* Cheers, Jim 2015-03-18 7:28 GMT+01:00 kumarraj rajitpro2...@gmail.com: Hi Jim, Yes, you are right.. that document is having price 499.99, But i want to consider the first record in the group as part of the main sort. Even though if i add price asc in the group.sort, but still the main sort does not consider that. group.sort=max(if(exists(query({!v='storeName_string:212'})),2,0),if(exists(query({!v='storeName_string:203'})),1,0)) desc,inStock_boolean descgeodist() asc,pricecommon_double ascsort=pricecommon_double desc Is there any other workaround so that sort is always based on the first record which is pulled up in each group? Regards, Raj -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266p4193658.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr returns incorrect results after sorting
Hi Jim, Yes, you are right.. that document is having price 499.99, But i want to consider the first record in the group as part of the main sort. Even though if i add price asc in the group.sort, but still the main sort does not consider that. group.sort=max(if(exists(query({!v='storeName_string:212'})),2,0),if(exists(query({!v='storeName_string:203'})),1,0)) desc,inStock_boolean descgeodist() asc,pricecommon_double ascsort=pricecommon_double desc Is there any other workaround so that sort is always based on the first record which is pulled up in each group? Regards, Raj -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266p4193658.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr returns incorrect results after sorting
Thanks David, that was a typo. Do you see any other issues? While solr does the grouping and if more than one document which are matched with given group.sort condition(numfound=2), then that particular document is not sorted correctly, when sorted by price.(sort=price) is applied across all the groups. Example: Below is the sample result. arr name=groups lst str name=groupValue10001/str result name=doclist numFound=1 start=0 doc double name=pricecommon_double729.97/double str name=code_string10001/str str name=name_textProduct1/str str name=storeName_string203/str double name=geodist()198.70324062133778/double/doc /result /lst lst str name=groupValue10002/str result name=doclist numFound=2 start=0 doc double name=pricecommon_double279.99/double str name=code_string10002/str str name=name_textProduct2/str str name=storeName_string212/str double name=geodist()0.0/double/doc /result /lst lst str name=groupValue10003/str result name=doclist numFound=1 start=0 doc double name=pricecommon_double479.99/double str name=code_string10003/str str name=name_textProduct3/str str name=storeName_string203/str double name=geodist()198.70324062133778/double/doc /result /lst I expect product 10002, to be sorted and shown after 1003, but it is not sorted correctly. -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266p4193457.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr returns incorrect results after sorting
Hi, Please note that you have two sort criteria, one to sort the documents inside each group and one to sort the groups. In the example you sent, the group 10002 has two documents and your group.limit is set to 1. If you redo the query with group.limit=2 I suspect that you'll see the second document of this group with a pricecommon_double between 479.99 and 729.97. This would mean that the sorting is correct ;). Bottom line is that when you have a group.sort different than the main sort, if the number of documents in one group is more than one then you cannot ensure that this document reflects the main sort. Try for instance group.sort=pricecommon_double asc (main sort inverse order) and you'll see that the sort inside each group is always applied after the main sort. This is the only way to meet the expectations ;). Cheers, Jim 2015-03-17 9:48 GMT+01:00 kumarraj rajitpro2...@gmail.com: Thanks David, that was a typo. Do you see any other issues? While solr does the grouping and if more than one document which are matched with given group.sort condition(numfound=2), then that particular document is not sorted correctly, when sorted by price.(sort=price) is applied across all the groups. Example: Below is the sample result. arr name=groups lst str name=groupValue10001/str result name=doclist numFound=1 start=0 doc double name=pricecommon_double729.97/double str name=code_string10001/str str name=name_textProduct1/str str name=storeName_string203/str double name=geodist()198.70324062133778/double/doc /result /lst lst str name=groupValue10002/str result name=doclist numFound=2 start=0 doc double name=pricecommon_double279.99/double str name=code_string10002/str str name=name_textProduct2/str str name=storeName_string212/str double name=geodist()0.0/double/doc /result /lst lst str name=groupValue10003/str result name=doclist numFound=1 start=0 doc double name=pricecommon_double479.99/double str name=code_string10003/str str name=name_textProduct3/str str name=storeName_string203/str double name=geodist()198.70324062133778/double/doc /result /lst I expect product 10002, to be sorted and shown after 1003, but it is not sorted correctly. -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266p4193457.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr returns incorrect results after sorting
I noticed you have an ‘’ immediately preceding the geodist() asc at the very end of the query/URL; that’s supposed to be a comma since group.sort is a comma delimited list of sorts. ~ David Smiley Freelance Apache Lucene/Solr Search Consultant/Developer http://www.linkedin.com/in/davidwsmiley On Mon, Mar 16, 2015 at 7:51 AM, kumarraj rajitpro2...@gmail.com wrote: Hi, I am using group.sort to internally sort the values first based on store(using function),then stock and finally distance and sort the output results based on price, but solr does not return the correct results after sorting. Below is the sample query: q=*:*start=0rows=200sort=pricecommon_double descd=321spatial=truesfield=store_locationfl=geodist(),*pt=37.1037311,-76.5104751 group.ngroups=truegroup.limit=1group.facet=truegroup.field=code_stringgroup=truegroup.sort=max(if(exists(query({!v='storeName_string:212'})),2,0),if(exists(query({!v='storeName_string:203'})),1,0)) desc,inStock_boolean descgeodist() asc I am expecting all the docs to be sorted by price from high to low after grouping, but i see the records not matching the order, Do you see any issues with the query or having functions in group.sort is not supported in solr? Regards, Raj -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266.html Sent from the Solr - User mailing list archive at Nabble.com.
Solr returns incorrect results after sorting
Hi, I am using group.sort to internally sort the values first based on store(using function),then stock and finally distance and sort the output results based on price, but solr does not return the correct results after sorting. Below is the sample query: q=*:*start=0rows=200sort=pricecommon_double descd=321spatial=truesfield=store_locationfl=geodist(),*pt=37.1037311,-76.5104751 group.ngroups=truegroup.limit=1group.facet=truegroup.field=code_stringgroup=truegroup.sort=max(if(exists(query({!v='storeName_string:212'})),2,0),if(exists(query({!v='storeName_string:203'})),1,0)) desc,inStock_boolean descgeodist() asc I am expecting all the docs to be sorted by price from high to low after grouping, but i see the records not matching the order, Do you see any issues with the query or having functions in group.sort is not supported in solr? Regards, Raj -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-returns-incorrect-results-after-sorting-tp4193266.html Sent from the Solr - User mailing list archive at Nabble.com.