Sort by Datetime?, null last on a lucene query

36 views
Skip to first unread message

Bruno

unread,
May 18, 2018, 5:50:26 PM5/18/18
to RavenDB - 2nd generation document database
Hi guys,
this seems simple but I'm not exactly being able to sort by a nullable Datetime field keeping nulls last in a lucene query. After every sort, the null entries come first.

However, for strings, after sorting the nulls do not come first.

My setup:
- Raven 3.5
- My index has this  property that I want to search and sort by:
   public DateTime? LastLogin { get; set; }

In the index def, I'm indexing it as:
Index(x => x.LastLogin, FieldIndexing.Analyzed);

No custom sort / no store.


Thoughts?


Thanks.

Oren Eini (Ayende Rahien)

unread,
May 19, 2018, 1:28:55 PM5/19/18
to ravendb
Null is also a value,and is sorts as NULL_VALUE
Dates are stored as lexical values.

Null dates should come last, unless you are using desc sort.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bruno

unread,
May 22, 2018, 11:59:33 AM5/22/18
to RavenDB - 2nd generation document database
Thanks for your reply Oren.

Turns out that upon further investigation, some of those records didn't have that property causing the sorting to malfunction (EMPTY_VALUE x NULL_VALUE?).


Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages