public ElasticSearchRequest <TIndexItem> CreateSearchRequestQuery(ISearchArgs searchArgs, Collection <TextSearchField <TIndexItem> > fieldsToSearch, ICollection <Func <QueryContainerDescriptor <TIndexItem>, QueryContainer> > filters = null) { Query = CreateQuery(searchArgs, fieldsToSearch, filters); Offset = searchArgs.Offset; Limit = searchArgs.Limit; return(this); }
public SearchModel(ISearchArgs <TFilter> args) { TFilter filter = args.Filter; if ((object)filter == null) { filter = new TFilter(); } this.Filter = filter; this.Pager = new PagerModel(args.Skip, args.Take); this.Records = new List <TRecord>(); this.SortBy = SearchModel <TRecord> .BuildSortBy(args.SortBy); }
IList<IEvent> IAPI.DoSearch(ISearchArgs args) { IList<IEvent> events = new List<IEvent>(); if (args == null || args.IsEmpty) { return events; } String xml = ((IAPI)this).Connection.MakeRequest( String.Format("{0}?{1}", API_URL, ConstructQueryString(args.ToArgs())) ); if (String.IsNullOrEmpty(xml)) { return events; } events = ((IAPI)this).Builder.Build(xml); return events; }
public SearchModel(ISearchArgs args) { this.Pager = new PagerModel(args.Skip, args.Take); this.Records = new List <TRecord>(); this.SortBy = SearchModel <TRecord> .BuildSortBy(args.SortBy); }
public SearchResult(ISearchArgs <TFilter> args) { this.Model = new SearchModel <TFilter, TRecord>(args); }
private static Func <QueryContainerDescriptor <TIndexItem>, QueryContainer> CreateQuery(ISearchArgs searchArgs, Collection <TextSearchField <TIndexItem> > textSearchFields, ICollection <Func <QueryContainerDescriptor <TIndexItem>, QueryContainer> > filters = null) { var boolQueryDescriptor = new BoolQueryDescriptor <TIndexItem>(); if (!string.IsNullOrWhiteSpace(searchArgs.SearchText)) { if (textSearchFields == null || !textSearchFields.Any()) { throw new ElasticSearchException("At least one text field need to be specified for text search"); } var textSearch = WildcardTextSearch(searchArgs.SearchText, textSearchFields); boolQueryDescriptor.Must(textSearch); } filters ??= new Collection <Func <QueryContainerDescriptor <TIndexItem>, QueryContainer> >(); boolQueryDescriptor.Filter(filters); QueryContainer Query(QueryContainerDescriptor <TIndexItem> q) => q.Bool(b => boolQueryDescriptor); return(Query); }
public async Task <ElasticSearchRequest <TIndexItem> > CreateSort(ISearchArgs searchArgs) { Sort = await CreateSort(searchArgs.SortOptions); return(this); }
public IList <Func <QueryContainerDescriptor <TIndexItem>, QueryContainer> > CreateFilters(ISearchArgs searchArgs) { IList <Func <QueryContainerDescriptor <TIndexItem>, QueryContainer> > filters = new List <Func <QueryContainerDescriptor <TIndexItem>, QueryContainer> >(); if (searchArgs.FiltersCriteria == null) { return(filters); } var duplicateFields = searchArgs.FiltersCriteria.GroupBy(field => $"{field.ParentPropertyName}.{field.PropertyName}") .Where(field => field.Count() > 1) .SelectMany(field => field) .ToList(); if (duplicateFields.Any()) { var filter = ComposeDuplicateFieldFilters(duplicateFields); filters.Add(filter); } foreach (var filterCriterion in searchArgs.FiltersCriteria.Except(duplicateFields)) { var filter = ComposeFilter(filterCriterion); filters.Add(filter); } return(filters); }
public SearchResult(ISearchArgs args) { this.Model = new SearchModel <TRecord>(args); }