c# - Having troubles in ordering search results using Lucene -
i running search query following bring results dynamics crm. search working fine brining results based on relevance. want order them in descending order of 'createdon' field. displaying 10 results per page, can't sort result returned query.
is there way order based on field?
public ienumerable<searchresult> search(string term, int? pagenumber, int pagesize, out int totalhits, ienumerable<string> logicalname) { var searchprovider = searchmanager.provider; var query = new crmentityquery(term, pagenumber.getvalueordefault(1), pagesize, logicalnames); return getsearchresults(out totalhits, searchprovider, query); } private ienumerable<searchresult> getsearchresults(out int totalhits, searchprovider searchprovider, crmentityquery query) { using (icrmentityindexsearcher searcher = searchprovider.getindexsearcher()) { portal.storerequestitem("searchdeduplicatelistforauthorisation", new list<guid>()); var results = searcher.search(query); totalhits = results.approximatetotalhits; return x in results select new searchresult(x); } }
not used lucene myself, cant comment on that.
however, if doing in basic crm. use queryexpression
orderexpression
. when page results paged in order.
here example of queryexpression
, orderexpression
, , paging.
page large result sets queryexpression
presumably @ point data being pulled out of crm, either within lucene, or own code, maybe in crmentityquery
? can add sort there.
Comments
Post a Comment