예제 #1
0
        public IActionResult GetInitial()
        {
            IQueryable <Index> allIndices = this._documentRepository.GetAllIndices();

            var indicesByField = IndexCollectionExtensions.AccumulateByField(allIndices);

            indicesByField = indicesByField.Take(InitialIndexDisplay_NumberOfFields).ToList();

            List <Facet> facets = new List <Facet>();

            foreach (var pair in indicesByField)
            {
                Facet newFacet = new Facet()
                {
                    Field = pair.Key,
                    Terms = pair.Value
                            .Take(InitialIndexDisplay_NumberOfTerms)
                            .Select(i => i.Term)
                            .ToList(),
                };
                facets.Add(newFacet);
            }

            return(this.Ok(facets));
        }
예제 #2
0
        private List <FacetDto> GetInitialFacets()
        {
            IQueryable <Index> allIndices = this._repository.GetAllIndices();
            var indicesByField            = IndexCollectionExtensions.AccumulateByField(allIndices);

            indicesByField = indicesByField.Take(InitialIndexDisplay_NumberOfFields).ToList();

            List <FacetDto> facets = new List <FacetDto>();

            foreach (var pair in indicesByField)
            {
                FacetDto newFacet = new FacetDto()
                {
                    Field = pair.Key,
                    Terms = pair.Value
                            .Take(InitialIndexDisplay_NumberOfTerms)
                            .Select(i => new TermDto()
                    {
                        Term = i.Term,
                    })
                            .ToList(),
                };
                facets.Add(newFacet);
            }

            return(facets);
        }