public async Task <IActionResult> Search(ISearchFunction searchFunction, HttpRequest request)
        {
            ISearchQuery query      = OpenSearchHelpers.CreateSearchQuery(request.Query, searchFunction);
            ISearchTask  searchTask = searchFunction.CreateSearch(query);

            if (searchTask is IResultSearchTask)
            {
                return(new ObjectResult(await((IResultSearchTask)searchTask).SearchResult()));
            }
            else
            {
                await searchTask.Search();

                return(new OkResult());
            }
        }
        public static ISearchQuery CreateSearchQuery(IQueryCollection queryCollection, ISearchFunction searchFunction)
        {
            List <SearchParameterSet> sets = new List <SearchParameterSet>();

            List <ISearchParameter> parameters = new List <ISearchParameter>();

            foreach (var kvp in queryCollection)
            {
                foreach (var value in kvp.Value)
                {
                    if (string.IsNullOrEmpty(value))
                    {
                        continue;
                    }
                    ISearchParameter parameter = CreateParameter(kvp.Key, kvp.Value, searchFunction.SearchCriterionSet);
                    if (parameter != null)
                    {
                        parameters.Add(parameter);
                    }
                }
            }
            SearchParameterSet set = new SearchParameterSet(parameters);

            sets.Add(set);

            return(new SearchQuery(sets.LastOrDefault()));
        }