public
class
MySearchResults : SearchResults
{
protected
override
SearchResults.ISearcher GetSearcher()
{
return
new
MySearcher(
this
);
}
protected
class
MySearcher : SearchResults.ISearcher
{
public
MySearcher(SearchResults control)
{
this
.control = control;
}
public
IEnumerable<Telerik.Sitefinity.Services.Search.Data.IDocument> Search(
string
query,
string
catalogue,
int
skip,
int
take,
out
int
hitCount)
{
var control =
this
.control;
var service = Telerik.Sitefinity.Services.ServiceBus.ResolveService<ISearchService>();
var queryBuilder = ObjectFactory.Resolve<IQueryBuilder>();
var searchQuery = queryBuilder.BuildQuery(query, control.SearchFields);
searchQuery.IndexName = catalogue;
searchQuery.Skip = skip;
searchQuery.Take = take;
searchQuery.OrderBy =
null
;
searchQuery.HighlightedFields = control.HighlightedFields;
// Contains the default filter - by current language
var currentFilter = searchQuery.Filter;
var myDatesFilter =
new
SearchFilter();
myDatesFilter.Operator = QueryOperator.And;
// Here we add a clause, that only results for the last 10 days will be displayed
myDatesFilter.AddClause(
new
SearchFilterClause(
"PublicationDate"
, DateTime.UtcNow.AddDays(-10), FilterOperator.Greater));
// Persist the language filter, if exists
if
(currentFilter !=
null
) myDatesFilter.AddFilter(currentFilter);
searchQuery.Filter = myDatesFilter;
IResultSet result = service.Search(searchQuery);
hitCount = result.HitCount;
return
result.SetContentLinks();
}
protected
readonly
SearchResults control;
}
}