London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
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