Exemple #1
0
        public BoboFacetQuery(ISearchContext searchContext, string category, Analyzer analyzer, string[] fields, LuceneSearchOptions searchOptions, BooleanOperation occurance)
            : base(searchContext, category, analyzer, fields, searchOptions, occurance)
        {
            _searchContext = searchContext;

            _request = new BoboFacetRequest
            {
                BrowseRequest = new BrowseRequest
                {
                    Query             = Query,
                    FetchStoredFields = true
                },
                FacetHandlers = new List <IFacetHandler>()
            };
        }
        public void PerformSearch(BoboFacetRequest request)
        {
            using (var boboReader = BoboIndexReader.GetInstance(Searcher.IndexReader, request.FacetHandlers))
                using (var browser = new BoboBrowser(boboReader))
                {
                    var results = browser.Browse(request.BrowseRequest);

                    _browseHits = results.Hits;

                    foreach (var facet in results.FacetMap)
                    {
                        Facets.Add(facet.Key, CreateFacetResult(facet.Value));
                    }

                    TotalItemCount = results.NumHits;
                }
        }
Exemple #3
0
        private BoboFacetRequest BuildRequest(int maxResults)
        {
            var request = new BoboFacetRequest
            {
                BrowseRequest = new BrowseRequest
                {
                    Query             = Query,
                    Sort              = SortFields.ToArray(),
                    Count             = maxResults,
                    FetchStoredFields = true
                },
                FacetHandlers = new List <IFacetHandler>()
            };

            foreach (var field in Fields)
            {
                var spec = new FacetSpec()
                {
                    MinHitCount = field.MinHits,
                    MaxCount    = field.MaxCount
                };

                request.BrowseRequest.SetFacetSpec(field.Name, spec);

                if (field.Values != null)
                {
                    request.BrowseRequest.AddSelection(new BrowseSelection(field.Name)
                    {
                        Values = field.Values
                    });
                }

                request.FacetHandlers.Add(new MultiValueFacetHandler(field.Name));
            }

            return(request);
        }
 public BoboFacetSearchResults(ISearchContext searchContext, BoboFacetRequest request)
     : base(searchContext)
 {
     PerformSearch(request);
 }