Custom sorting in RavenDB 2.5

80 views
Skip to first unread message

Esben Bugge

unread,
Jul 26, 2017, 9:41:01 AM7/26/17
to RavenDB - 2nd generation document database
Can I use custom sorting in RavenDB 2.5 with DatabaseCommands? I am already using IndexQuery.SortedFields to sort by a specific field at query time, but although this works fine in 2.5, the SortedFields property does not seem to be documented in this version of RavenDB.

I found this on custom sorting in 3.5 but I am not sure how to get it to work in 2.5, as Constants.CustomSortFieldName is not found in this version:

QueryResult result = store .DatabaseCommands .Query( "Employees/ByFirstName", new IndexQuery { SortedFields = new[] { new SortedField( Constants.CustomSortFieldName + "-" + // "-" - descending, "" - ascending ";" + typeof(SortByNumberOfCharactersFromEnd).AssemblyQualifiedName) }, TransformerParameters = new Dictionary<string, RavenJToken> { { "len", 1 } } });

Also, can I use alphanumeric ordering when querying in 2.5 with DatabaseCommands? Alphanumeric ordering is explained for 3.5 in the link above, but again I am missing a constant in 2.5 (this time it is Constants.AlphaNumericFieldName).

Esben Bugge

unread,
Jul 26, 2017, 9:44:46 AM7/26/17
to RavenDB - 2nd generation document database
Perhaps I misread the documentation and Constants.CustomSortFieldName and Constants.AlphaNumericFieldName is not refering to constants in Raven.Abstractions.Data.Constants? I may have been confused by the fact that Constants.TemporaryScoreValue is found here.. If so, I am sorry for the inconvenience!

Grisha Kotler

unread,
Jul 26, 2017, 10:04:11 AM7/26/17
to rav...@googlegroups.com
Hi,

Custom sorting is available starting from v3.0.
Alphanumeric sorting is a new feature in v3.5.

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Grisha Kotler l RavenDB Core Team Developer Mobile: +972-54-586-8647

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

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/


--
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.

Esben Bugge

unread,
Nov 24, 2017, 9:42:45 AM11/24/17
to RavenDB - 2nd generation document database
Hi Grisha

In 2.5 we can set sort options on a field in the index as

Sort(x => x.Name, SortOptions.Int);

With this, it seems to perform alphanumeric sorting when I sort on "Name" at query time. What do you mean when you write that alphanumeric sorting is a new feature in 3.5?
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Nov 25, 2017, 6:07:09 AM11/25/17
to ravendb
The sort options you have there is not actually doing alphanumeric sorting. It may accidentally look like it, but it is an invalid configuration and would probably break in interesting ways.

Hibernating Rhinos Ltd  

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

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