AI OnAI Off
var query = SearchClient.Instance.Search<EducationEventPage>(Language.Swedish)
.For(querystring)
.InField(x => x.SearchableTitle)
....
.Filter(filterForSpecialization)
.Filter(filterForProvider.filterBuilder)
....
if (string.IsNullOrEmptyWhitespace(querystring)) {
query = query.OrderBy(x => x.SearchableTitle);
}
var searchResult = query.GetContentResult();
Hi, i am wondering if there is a elegant way to to add .orderby when there is no query string and only filters for the query. That is, the same query code should not add a orderby when there is a querystring (sort order relevance) and do a orderby when querystring is empty:
var searchResults = SearchClient.Instance.Search(Language.Swedish)
.For(querystring)
.InField(x => x.SearchableTitle)
....
.Filter(filterForSpecialization)
.Filter(filterForProvider.filterBuilder)
....
.OrderBy(x => x.SearchableTitle) // should only be applied when querystring = ""
.GetContentResult();
Any ideas?
Regards
Magnus