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 Scott K <so...@skister.com> on 2011/03/02 20:52:32 UTC
sort by price puts unknown prices first
When I sort by price ascending, documents with no price are listed
first. I would like them listed last. I tried adding the
sortMissingLast flag, even though it says it is only for strings, but
it did not help. Why doesn't sortMissingLast work on non-strings? This
seems like a very common issue, but I couldn't find any solutions when
I searched this group and on google.
The map function almost works, but if I use this, then prices of 0 are
treated as null, which is not what I want.
sort=map(price,0,0,9999999999)+asc
schema.xml:
<fieldType name="tfloat" class="solr.TrieFloatField"
precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<field name="price" type="tfloat" indexed="true" sortMissingLast="true" />
Thanks, Scott
Re: sort by price puts unknown prices first
Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Wed, Mar 2, 2011 at 4:19 PM, Scott K <so...@skister.com> wrote:
> On Wed, Mar 2, 2011 at 12:21, Chris Hostetter <ho...@fucit.org> wrote:
>> historicly it has been because of a fundemental limitation in how the
>> Lucene FieldCache has historicly worked where the array backed FieldCaches
>> use the default numeric value (ie: 0) when docs have no value (but in the
>> case of Strings, the default is "null" which is easy to test for)
>>
>> i am 99.99% certain this has changed on the trunk, so all of the
>> Trie*Fields should support the sortMissing* options in 4.x
>
> I am running a 4.x build and just tried the most recent nightly build,
> apache-solr-4.0-2011-03-02_08-06-07.tgz, and am still seeing this
> issue.
Hmmm, this looks like maybe a bug.
It works if you put sortMissingLast="true" on the fieldType, but not
if it's just on the field.
For now, work around by adding it to the fieldType, and I'll investigate.
-Yonik
http://lucidimagination.com
Re: sort by price puts unknown prices first
Posted by Scott K <so...@skister.com>.
On Wed, Mar 2, 2011 at 12:21, Chris Hostetter <ho...@fucit.org> wrote:
> historicly it has been because of a fundemental limitation in how the
> Lucene FieldCache has historicly worked where the array backed FieldCaches
> use the default numeric value (ie: 0) when docs have no value (but in the
> case of Strings, the default is "null" which is easy to test for)
>
> i am 99.99% certain this has changed on the trunk, so all of the
> Trie*Fields should support the sortMissing* options in 4.x
I am running a 4.x build and just tried the most recent nightly build,
apache-solr-4.0-2011-03-02_08-06-07.tgz, and am still seeing this
issue.
Other than creating a new indexed field where I manually map no value
to a high number, is there a way to sort on a function query that puts
undefined values to the end? Is there no way to use map to change
undefined values?
Thanks, Scott
Re: sort by price puts unknown prices first
Posted by Chris Hostetter <ho...@fucit.org>.
: When I sort by price ascending, documents with no price are listed
: first. I would like them listed last. I tried adding the
: sortMissingLast flag, even though it says it is only for strings, but
it works for any field type *backed* by a string, including the
SortableIntField (and it's breathren)
: it did not help. Why doesn't sortMissingLast work on non-strings? This
: seems like a very common issue, but I couldn't find any solutions when
: I searched this group and on google.
historicly it has been because of a fundemental limitation in how the
Lucene FieldCache has historicly worked where the array backed FieldCaches
use the default numeric value (ie: 0) when docs have no value (but in the
case of Strings, the default is "null" which is easy to test for)
i am 99.99% certain this has changed on the trunk, so all of the
Trie*Fields should support the sortMissing* options in 4.x
-Hoss