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 Derek Poh <dp...@globalsources.com> on 2015/05/27 10:36:02 UTC

sort on fields that are not mandatory in each document

Hi

I am trying to sort on multiple fields. These fields donot necessary 
exist in every document.
sort=sppddrank asc, ddrank asc

 From the sorted result, it seems that documents which donot have 
sppddrank field is at the top.

How can I make the documents that have the sppddrank field to be on top 
and sortedby it and those documents which do not have the field below?

-Derek


Re: sort on fields that are not mandatory in each document

Posted by Derek Poh <dp...@globalsources.com>.
Got it. Thank you Rajani.
On 5/27/2015 5:34 PM, Rajani Maski wrote:
> Hi Derek,
>
> They are at the fieldType Level. You might find some reference examples in
> schema.xml using them.
>
> https://cwiki.apache.org/confluence/display/solr/Field+Type+Definitions+and+Properties
>
> On Wed, May 27, 2015 at 2:30 PM, Derek Poh <dp...@globalsources.com> wrote:
>
>> Hi Ahmet
>>
>> The sortMissingLast and sortMissingFirst attributes are defined at the
>> field or fieldType level?
>>
>> <field name="P_TSRank" type="int" indexed="true" stored="true"
>> multiValued="false"/>
>>
>> <fieldType name="int" class="solr.TrieIntField" precisionStep="0"
>> positionIncrementGap="0"/>
>>
>>
>> On 5/27/2015 4:43 PM, Ahmet Arslan wrote:
>>
>>> Hi,
>>> I think you are looking for sortMissing* attributes:
>>>
>>> sortMissingLast and sortMissingFirst attributes are optional attributes
>>> are
>>> currently supported on types that are sorted internally as strings
>>> and on numeric types.
>>>
>>> Ahmet
>>>
>>> On Wednesday, May 27, 2015 11:36 AM, Derek Poh <dp...@globalsources.com>
>>> wrote:
>>> Hi
>>>
>>> I am trying to sort on multiple fields. These fields donot necessary
>>> exist in every document.
>>> sort=sppddrank asc, ddrank asc
>>>
>>> >From the sorted result, it seems that documents which donot have
>>> sppddrank field is at the top.
>>>
>>> How can I make the documents that have the sppddrank field to be on top
>>> and sortedby it and those documents which do not have the field below?
>>>
>>> -Derek
>>>
>>>
>>>


Re: sort on fields that are not mandatory in each document

Posted by Derek Poh <dp...@globalsources.com>.
Oh ok. Thank youAlessandro.

On 5/27/2015 6:07 PM, Alessandro Benedetti wrote:
> Actually it is both field level and field type level.
> You decide based on your use case ( can happen that for the same field type
> , you want sortMissingFirst for one field, and sortMissingLast for another)
> .
>
> I want to add a bonus note, related the ""( empty ) and null concept.
>
> Be very careful you don't index empty values for your fields or this will
> mess up the sorting.
> Solr manage the missing values ( that are null values), and does not manage
> the empty "" values.
>
> Those values for a human are identical to null values, but not for solr.
> So you can have very weird situations for your users.
> So , to be sure everything work nice with sortMissing attribute, be sure to
> not index empty values.
>
> Cheers
>
> 2015-05-27 10:34 GMT+01:00 Rajani Maski <ra...@lucidworks.com>:
>
>> Hi Derek,
>>
>> They are at the fieldType Level. You might find some reference examples in
>> schema.xml using them.
>>
>>
>> https://cwiki.apache.org/confluence/display/solr/Field+Type+Definitions+and+Properties
>>
>> On Wed, May 27, 2015 at 2:30 PM, Derek Poh <dp...@globalsources.com> wrote:
>>
>>> Hi Ahmet
>>>
>>> The sortMissingLast and sortMissingFirst attributes are defined at the
>>> field or fieldType level?
>>>
>>> <field name="P_TSRank" type="int" indexed="true" stored="true"
>>> multiValued="false"/>
>>>
>>> <fieldType name="int" class="solr.TrieIntField" precisionStep="0"
>>> positionIncrementGap="0"/>
>>>
>>>
>>> On 5/27/2015 4:43 PM, Ahmet Arslan wrote:
>>>
>>>> Hi,
>>>> I think you are looking for sortMissing* attributes:
>>>>
>>>> sortMissingLast and sortMissingFirst attributes are optional attributes
>>>> are
>>>> currently supported on types that are sorted internally as strings
>>>> and on numeric types.
>>>>
>>>> Ahmet
>>>>
>>>> On Wednesday, May 27, 2015 11:36 AM, Derek Poh <dp...@globalsources.com>
>>>> wrote:
>>>> Hi
>>>>
>>>> I am trying to sort on multiple fields. These fields donot necessary
>>>> exist in every document.
>>>> sort=sppddrank asc, ddrank asc
>>>>
>>>> >From the sorted result, it seems that documents which donot have
>>>> sppddrank field is at the top.
>>>>
>>>> How can I make the documents that have the sppddrank field to be on top
>>>> and sortedby it and those documents which do not have the field below?
>>>>
>>>> -Derek
>>>>
>>>>
>>>>
>
>


Re: sort on fields that are not mandatory in each document

Posted by Alessandro Benedetti <be...@gmail.com>.
Actually it is both field level and field type level.
You decide based on your use case ( can happen that for the same field type
, you want sortMissingFirst for one field, and sortMissingLast for another)
.

I want to add a bonus note, related the ""( empty ) and null concept.

Be very careful you don't index empty values for your fields or this will
mess up the sorting.
Solr manage the missing values ( that are null values), and does not manage
the empty "" values.

Those values for a human are identical to null values, but not for solr.
So you can have very weird situations for your users.
So , to be sure everything work nice with sortMissing attribute, be sure to
not index empty values.

Cheers

2015-05-27 10:34 GMT+01:00 Rajani Maski <ra...@lucidworks.com>:

> Hi Derek,
>
> They are at the fieldType Level. You might find some reference examples in
> schema.xml using them.
>
>
> https://cwiki.apache.org/confluence/display/solr/Field+Type+Definitions+and+Properties
>
> On Wed, May 27, 2015 at 2:30 PM, Derek Poh <dp...@globalsources.com> wrote:
>
> > Hi Ahmet
> >
> > The sortMissingLast and sortMissingFirst attributes are defined at the
> > field or fieldType level?
> >
> > <field name="P_TSRank" type="int" indexed="true" stored="true"
> > multiValued="false"/>
> >
> > <fieldType name="int" class="solr.TrieIntField" precisionStep="0"
> > positionIncrementGap="0"/>
> >
> >
> > On 5/27/2015 4:43 PM, Ahmet Arslan wrote:
> >
> >> Hi,
> >> I think you are looking for sortMissing* attributes:
> >>
> >> sortMissingLast and sortMissingFirst attributes are optional attributes
> >> are
> >> currently supported on types that are sorted internally as strings
> >> and on numeric types.
> >>
> >> Ahmet
> >>
> >> On Wednesday, May 27, 2015 11:36 AM, Derek Poh <dp...@globalsources.com>
> >> wrote:
> >> Hi
> >>
> >> I am trying to sort on multiple fields. These fields donot necessary
> >> exist in every document.
> >> sort=sppddrank asc, ddrank asc
> >>
> >> >From the sorted result, it seems that documents which donot have
> >> sppddrank field is at the top.
> >>
> >> How can I make the documents that have the sppddrank field to be on top
> >> and sortedby it and those documents which do not have the field below?
> >>
> >> -Derek
> >>
> >>
> >>
> >
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Re: sort on fields that are not mandatory in each document

Posted by Rajani Maski <ra...@lucidworks.com>.
Hi Derek,

They are at the fieldType Level. You might find some reference examples in
schema.xml using them.

https://cwiki.apache.org/confluence/display/solr/Field+Type+Definitions+and+Properties

On Wed, May 27, 2015 at 2:30 PM, Derek Poh <dp...@globalsources.com> wrote:

> Hi Ahmet
>
> The sortMissingLast and sortMissingFirst attributes are defined at the
> field or fieldType level?
>
> <field name="P_TSRank" type="int" indexed="true" stored="true"
> multiValued="false"/>
>
> <fieldType name="int" class="solr.TrieIntField" precisionStep="0"
> positionIncrementGap="0"/>
>
>
> On 5/27/2015 4:43 PM, Ahmet Arslan wrote:
>
>> Hi,
>> I think you are looking for sortMissing* attributes:
>>
>> sortMissingLast and sortMissingFirst attributes are optional attributes
>> are
>> currently supported on types that are sorted internally as strings
>> and on numeric types.
>>
>> Ahmet
>>
>> On Wednesday, May 27, 2015 11:36 AM, Derek Poh <dp...@globalsources.com>
>> wrote:
>> Hi
>>
>> I am trying to sort on multiple fields. These fields donot necessary
>> exist in every document.
>> sort=sppddrank asc, ddrank asc
>>
>> >From the sorted result, it seems that documents which donot have
>> sppddrank field is at the top.
>>
>> How can I make the documents that have the sppddrank field to be on top
>> and sortedby it and those documents which do not have the field below?
>>
>> -Derek
>>
>>
>>
>

Re: sort on fields that are not mandatory in each document

Posted by Derek Poh <dp...@globalsources.com>.
Hi Ahmet

The sortMissingLast and sortMissingFirst attributes are defined at the 
field or fieldType level?

<field name="P_TSRank" type="int" indexed="true" stored="true" 
multiValued="false"/>

<fieldType name="int" class="solr.TrieIntField" precisionStep="0" 
positionIncrementGap="0"/>

On 5/27/2015 4:43 PM, Ahmet Arslan wrote:
> Hi,
> I think you are looking for sortMissing* attributes:
>
> sortMissingLast and sortMissingFirst attributes are optional attributes are
> currently supported on types that are sorted internally as strings
> and on numeric types.
>
> Ahmet
>
> On Wednesday, May 27, 2015 11:36 AM, Derek Poh <dp...@globalsources.com> wrote:
> Hi
>
> I am trying to sort on multiple fields. These fields donot necessary
> exist in every document.
> sort=sppddrank asc, ddrank asc
>
> >From the sorted result, it seems that documents which donot have
> sppddrank field is at the top.
>
> How can I make the documents that have the sppddrank field to be on top
> and sortedby it and those documents which do not have the field below?
>
> -Derek
>
>


Re: sort on fields that are not mandatory in each document

Posted by Ahmet Arslan <io...@yahoo.com.INVALID>.
Hi,
I think you are looking for sortMissing* attributes:

sortMissingLast and sortMissingFirst attributes are optional attributes are
currently supported on types that are sorted internally as strings
and on numeric types.

Ahmet

On Wednesday, May 27, 2015 11:36 AM, Derek Poh <dp...@globalsources.com> wrote:
Hi

I am trying to sort on multiple fields. These fields donot necessary 
exist in every document.
sort=sppddrank asc, ddrank asc

>From the sorted result, it seems that documents which donot have 
sppddrank field is at the top.

How can I make the documents that have the sppddrank field to be on top 
and sortedby it and those documents which do not have the field below?

-Derek