Ejemplo n.º 1
0
        private MultiFacetRequest BuildRequest(int maxResults)
        {
            var request = new MultiFacetRequest
            {
                Query      = Query,
                Sort       = SortFields.ToList(),
                MaxResults = maxResults,
                Config     = FacetSearcherConfiguration.Default(),
                Facets     = new List <FacetFieldInfo>()
            };

            foreach (var field in Fields)
            {
                if (field.MinHits > 0)
                {
                    request.Config.MinimumCountInTotalDatasetForFacet = field.MinHits;
                }

                var fieldInfo = new FacetFieldInfo
                {
                    FieldName = field.Name,
                    MaxToFetchExcludingSelections = field.MaxCount
                };

                if (field.Values != null)
                {
                    fieldInfo.Selections = field.Values.ToList();
                }

                request.Facets.Add(fieldInfo);
            }

            return(request);
        }