public override void Process(ApplyFacetArgs args) { if (!IsSimpleFacet(args.FacetItem)) { return; } var selectedValues = args.SearchParameters.SelectedFacets?.FirstOrDefault(x => x.FacetId == args.FacetItem.ID.Guid)?.SelectedValues; if (selectedValues == null || !selectedValues.Any()) { return; } var indexProp = args.FacetItem.IndexProperty; if (string.IsNullOrWhiteSpace(indexProp)) { return; } var facetPredicate = PredicateBuilder.True <SearchResultItem>(); foreach (var value in selectedValues) { facetPredicate = args.FacetItem.UseAnd? facetPredicate.And(x => x[indexProp] == value) : facetPredicate.Or(x => x[indexProp] == value); } args.Query = args.Query.Where(facetPredicate); }
public override void Process(ApplyFacetArgs args) { if (!IsSimpleFacet(args.FacetItem)) { return; } var indexProp = args.FacetItem.IndexProperty; if (string.IsNullOrWhiteSpace(indexProp)) { Log.Warn($"Nimble:ApplyFacet:ListFacet: Missing Expected indexProp. Skipping facet {args.FacetItem.DisplayName}, {args.FacetItem.ID}", this); return; } var minValues = args.FacetItem.MinimumValues; args.Query = args.Query.FacetOn(x => x[indexProp], minValues); }
public IQueryable <SearchResultItem> ApplyFacetOn(IQueryable <SearchResultItem> query, FacetItem[] facets, SearchParameters searchParameters) { if (facets == null || !facets.Any()) { return(query); } // Run Facets var facetArgs = new ApplyFacetArgs { SearchParameters = searchParameters, Query = query }; foreach (var facet in facets) { facetArgs.FacetItem = facet; CorePipeline.Run(Pipeline.ApplyFacetOn, facetArgs); } return(facetArgs.Query); }