Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have looked at the documentation, but can't find anything definitive on how to sort descending by a field in Umbraco using Examine. (I can sort Ascending fine!). I'd like to sort by create Date, descending.... so this is what I have
<IndexSet SetName="NewsAndPressCyIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/NewsAndPressCy/" IndexParentId="1052"> <IndexAttributeFields> <add Name="id" /> <add Name="nodeName" /> <add Name="createDate" EnableSorting="true" Type="DateTime" /> <add Name="path" /> </IndexAttributeFields> <IndexUserFields> <add Name="articleHeadline" /> <add Name="articleContent" /> </IndexUserFields> <IncludeNodeTypes> <add Name="NewsArticle" /> </IncludeNodeTypes> <ExcludeNodeTypes> </ExcludeNodeTypes>
And then in my c#
string searchProviderCollection = Library.Languages.LanguageHelper.GetLanguageNameFromNodeId(Node.GetCurrent().Id) == "cy-GB" ? "NewsAndPressCySearcher" : "NewsAndPressEnSearcher"; BaseSearchProvider searcher = Examine.ExamineManager.Instance.SearchProviderCollection[searchProviderCollection]; ISearchCriteria searchCriteria = searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or); StringBuilder searchQueryString = new StringBuilder(); ... build up search string etc etc etc ISearchCriteria searchQuery = searchCriteria.RawQuery(searchQueryString.ToString());//rderByDescending();//rderByDescending(new string[] { "createDate" }); //searchQuery.OrderByDescending(); ISearchResults searchResults = searcher.Search(searchQuery);//rderByDescending(x => x.Fields.["createDate"]);//
Where do I specify that I would like to search Descending?
Not sure you can set sort with raw query. I have done it with fluent api although i had to format the date using Document writing event see http://thecogworks.co.uk/blog/2013/04/11/examiness-hints-and-tips-from-the-trenches-part-10-document-writing-redux
Regards
Ismail
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Sorting descending with Examine
I have looked at the documentation, but can't find anything definitive on how to sort descending by a field in Umbraco using Examine. (I can sort Ascending fine!). I'd like to sort by create Date, descending.... so this is what I have
And then in my c#
Where do I specify that I would like to search Descending?
Not sure you can set sort with raw query. I have done it with fluent api although i had to format the date using Document writing event see http://thecogworks.co.uk/blog/2013/04/11/examiness-hints-and-tips-from-the-trenches-part-10-document-writing-redux
Regards
Ismail
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.