I am trying to sort my search results by a custom Umbraco property I have created - let's call it sortDate.
Inside my IndexSet, in config/ExamineIndex.config
I have this:
<IndexUserFields>
<add Name="sortDate" EnableSorting="true" Type="DateTime" />
...
In my Search user control, I am constructing a criteria
and filter
and using them to search like so:
var criteria =
ExamineManager.Instance.SearchProviderCollection["MySearcher"].CreateSearchCriteria(
UmbracoExamine开发者_运维问答.IndexTypes.Content);
var filter =
criteria.GroupedOr(new string[] { "sortDate", "someThing", "someThingElse", "bodyText" }, SearchTerm.ToLower()).Compile();
var MySearchResults =
ExamineManager.Instance.SearchProviderCollection["MySearcher"].Search(filter).Distinct();
I'm guessing I need to add something to specify how Lucene should sort this on my filter?
This is Umbraco 4.6.1 if that matters :)
OK, not sure how I missed this, but it looks like you can just do:
filter.OrderBy( new string[] { "sortDate" } );
精彩评论