Then I do this to get my results, but they are not ordered by the sort date field :
var searchCriteria = ExamineManager.Instance.DefaultSearchProvider.CreateSearchCriteria(IndexTypes.Content);
var query = searchCriteria.Field("nodeTypeAlias", "NewsDetailPage").OrderByDescending("__newsSortDate");
var results = ExamineManager.Instance.DefaultSearchProvider.Search(query.Compile());
The sort part you will never see in the generated query as the sorting is done in bowels of lucene. After you implemented this code did you rebuild your index? Also can you show me screen grab of a record in the index using luke?
You have in document writing event _newsSortDate change it to _Sort_newsDate then in your sort code just do .OrderByDescending("newsDate") that should work.
Examine ordering results
Hi,
I'm trying to order the results of my examine query.
According to the docs this should be possible by adding it to the query : https://github.com/Shazwazza/Examine/wiki/Sorting-results
But can't get it to work :
I use this code in the document writing even of examine for adding a extra field to the index that I do the sorting on :
This is based on this article : https://thecogworks.com/blog/posts/examiness-hints-and-tips-from-the-trenches-part-10-document-writing-redux/
Then I do this to get my results, but they are not ordered by the sort date field :
If I output the query I see this :
So no indication of sorting there.
Any ideas on why this is happening. I can always sort the results themselves when I get them. But would be better to have them already sorted
Umbraco 7.5.14 and Examine 0.1.82
Dave,
The sort part you will never see in the generated query as the sorting is done in bowels of lucene. After you implemented this code did you rebuild your index? Also can you show me screen grab of a record in the index using luke?
Regards
Ismail
Hi,
Ismail I rebuild the index several times. Also tried to remove __ in the field name.
This what I see in Luke for the field :
Dave
Dave,
That looks ok. When injecting the field keep __ however in your query try
Does that work? Basically under the hood examine will use __
If that dont work and if you have time can you jump on skype and show me whats going? Im on ismail_mayat
Doesn't have any effect.
Maybe will have a look again next week when I have more time.
Dave
I tried the same thing as described here in the unit test
https://github.com/Shazwazza/Examine/blob/5999c711230b76db0a037120a8467eaf88eb8d9f/src/Examine.Test/Search/FluentApiTests.cs
But that does not influence the order of the results as well
Dave
I say we leave it till uk fest and we can work through it, i can haz power to make it work lol. I have done it plenty of times
Dave,
You have in document writing event _newsSortDate change it to _Sort_newsDate then in your sort code just do .OrderByDescending("newsDate") that should work.
Regards
Ismail
is working on a reply...