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 joeMcElroy <ph...@gmail.com> on 2008/11/26 17:00:33 UTC

omiting no price documents when sorting on price

im sure this is an easy question but...

when a product doesn't have a price, I index the price as 0. When sorting on
price, these values come up first or last. How can you omit these items when
sorting against price. 

thanks

joe 
-- 
View this message in context: http://www.nabble.com/omiting-no-price-documents-when-sorting-on-price-tp20703795p20703795.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: omiting no price documents when sorting on price

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
You can omit documents.  I recommend doing it with a filter query.   
Append the following to your request to Solr:

     &fq=-price:0

That does the trick?  You'll have to have client logic to only add  
that parameter when sorting by price, if that's how you want it to work.

	Erik


On Nov 27, 2008, at 4:59 AM, joeMcElroy wrote:

>
> was hoping there was an option to omit results with a certain value  
> to stop
> certain fields containing 0 skewing the search results.
>
> i will try not sending the field if its 0. cheers!
>
> joe
>
>
> joeMcElroy wrote:
>>
>> im sure this is an easy question but...
>>
>> when a product doesn't have a price, I index the price as 0. When  
>> sorting
>> on price, these values come up first or last. How can you omit  
>> these items
>> when sorting against price.
>>
>> thanks
>>
>> joe
>>
>
> -- 
> View this message in context: http://www.nabble.com/omiting-no-price-documents-when-sorting-on-price-tp20703795p20716352.html
> Sent from the Solr - User mailing list archive at Nabble.com.


Re: omiting no price documents when sorting on price

Posted by joeMcElroy <ph...@gmail.com>.
was hoping there was an option to omit results with a certain value to stop
certain fields containing 0 skewing the search results.

i will try not sending the field if its 0. cheers!

joe


joeMcElroy wrote:
> 
> im sure this is an easy question but...
> 
> when a product doesn't have a price, I index the price as 0. When sorting
> on price, these values come up first or last. How can you omit these items
> when sorting against price. 
> 
> thanks
> 
> joe 
> 

-- 
View this message in context: http://www.nabble.com/omiting-no-price-documents-when-sorting-on-price-tp20703795p20716352.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: omiting no price documents when sorting on price

Posted by Chris Hostetter <ho...@fucit.org>.
: when a product doesn't have a price, I index the price as 0. When sorting on
: price, these values come up first or last. How can you omit these items when
: sorting against price. 

FWIW: i'm not sure if by "omit these items" you really mean "don't include 
them in the results at all" .. in which case a simple "fq" will help 
eliminate them, but this is exactly the motivation for the 
"sortMissingLast" and "sortMissingFirst" options (which are obviously 
mutually exclusive)

that way if someone searches for all products matching "iphone" you can 
correctly tell them there are are 274, even if you only have pricing data 
for 33 of them -- and no matter what direction they sort (price low-high 
or price high-low) the 241 w/o prices will be at the end of the list.


-Hoss


Re: omiting no price documents when sorting on price

Posted by Matthew Runo <mr...@zappos.com>.
You also don't /need/ to put in a price in the index. If something  
doesn't have a value for a field, you can just not send the field.  
Then sorting won't be thrown off by the dummy value. Then those  
documents simply won't have a "price" field.

Of course, if you need to facet on it or query it or anything like  
that you can't do this..

Thanks for your time!

Matthew Runo
Software Engineer, Zappos.com
mruno@zappos.com - 702-943-7833

On Nov 26, 2008, at 9:09 AM, Erick Erickson wrote:

> Assuming you know you want to do this at query time, couldn't
> you just add a -price:0 clause to your query?
>
> Best
> Erick
>
> On Wed, Nov 26, 2008 at 11:00 AM, joeMcElroy <ph...@gmail.com> wrote:
>
>>
>> im sure this is an easy question but...
>>
>> when a product doesn't have a price, I index the price as 0. When  
>> sorting
>> on
>> price, these values come up first or last. How can you omit these  
>> items
>> when
>> sorting against price.
>>
>> thanks
>>
>> joe
>> --
>> View this message in context:
>> http://www.nabble.com/omiting-no-price-documents-when-sorting-on-price-tp20703795p20703795.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>


Re: omiting no price documents when sorting on price

Posted by Erick Erickson <er...@gmail.com>.
Assuming you know you want to do this at query time, couldn't
you just add a -price:0 clause to your query?

Best
Erick

On Wed, Nov 26, 2008 at 11:00 AM, joeMcElroy <ph...@gmail.com> wrote:

>
> im sure this is an easy question but...
>
> when a product doesn't have a price, I index the price as 0. When sorting
> on
> price, these values come up first or last. How can you omit these items
> when
> sorting against price.
>
> thanks
>
> joe
> --
> View this message in context:
> http://www.nabble.com/omiting-no-price-documents-when-sorting-on-price-tp20703795p20703795.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>