/// <summary>
        /// Generates a merged BrowseResult from the supplied <see cref="T:BrowseRequest"/>.
        /// The results are put into a Lucene.Net <see cref="T:Lucene.Net.Search.Collector"/> and a <see cref="T:System.Collections.Generic.IDictionary{System.String, IFacetAccessible}"/>.
        /// </summary>
        /// <param name="req"><see cref="T:BrowseRequest"/> for generating the facets.</param>
        /// <param name="hitCollector">A <see cref="T:Lucene.Net.Search.Collector"/> for the hits generated during a search.</param>
        /// <param name="facetMap">A dictionary of all of the facet collections (output).</param>
        /// <param name="start">The offset value for the document number.</param>
        public virtual void Browse(
            BrowseRequest req,
            Collector hitCollector,
            IDictionary <string, IFacetAccessible> facetMap,
            int start)
        {
            Weight w = null;

            try
            {
                var q = req.Query;
                MatchAllDocsQuery matchAllDocsQuery = new MatchAllDocsQuery();
                if (q == null)
                {
                    q = matchAllDocsQuery;
                }
                else if (!(q is MatchAllDocsQuery))
                {
                    //MatchAllQuery is needed to filter out the deleted docids, that reside in ZoieSegmentReader and are not visible on Bobo level
                    matchAllDocsQuery.Boost = 0f;
                    q = QueriesSupport.CombineAnd(matchAllDocsQuery, q);
                }
                w = CreateWeight(q);
            }
            catch (Exception ioe)
            {
                throw new BrowseException(ioe.Message, ioe);
            }

            Browse(req, w, hitCollector, facetMap, start);
        }
Example #2
0
        /// <summary>
        /// Generates a merged BrowseResult from the supplied <see cref="T:BrowseRequest"/>.
        /// The results are put into a Lucene.Net <see cref="T:Lucene.Net.Search.Collector"/> and a <see cref="T:System.Collections.Generic.IDictionary{System.String, IFacetAccessible}"/>.
        /// </summary>
        /// <param name="req"><see cref="T:BrowseRequest"/> for generating the facets.</param>
        /// <param name="hitCollector">A <see cref="T:Lucene.Net.Search.Collector"/> for the hits generated during a search.</param>
        /// <param name="facetMap">A dictionary of all of the facet collections (output).</param>
        /// <param name="start">The offset value for the document number.</param>
        public virtual void Browse(
            BrowseRequest req,
            ICollector hitCollector,
            IDictionary <string, IFacetAccessible> facetMap,
            int start)
        {
            // index empty
            if (m_subBrowsers == null || m_subBrowsers.Length == 0)
            {
                return;
            }

            try
            {
                var q = req.Query;
                MatchAllDocsQuery matchAllDocsQuery = new MatchAllDocsQuery();
                if (q == null)
                {
                    q = matchAllDocsQuery;
                }
                else if (!(q is MatchAllDocsQuery))
                {
                    //MatchAllQuery is needed to filter out the deleted docids, that reside in ZoieSegmentReader and are not visible on Bobo level
                    matchAllDocsQuery.Boost = 0f;
                    q = QueriesSupport.CombineAnd(matchAllDocsQuery, q);
                }
                req.Query = q;
            }
            catch (Exception ioe)
            {
                throw new BrowseException(ioe.Message, ioe);
            }

            var mergedMap = new Dictionary <string, IList <IFacetAccessible> >();

            try
            {
                var facetColMap = new Dictionary <string, IFacetAccessible>();
                for (int i = 0; i < m_subBrowsers.Length; i++)
                {
                    try
                    {
                        m_subBrowsers[i].Browse(req, hitCollector, facetColMap, (start + ReaderBase(i)));
                    }
                    finally
                    {
                        foreach (var entry in facetColMap)
                        {
                            string           name          = entry.Key;
                            IFacetAccessible facetAccessor = entry.Value;
                            var list = mergedMap.Get(name);
                            if (list == null)
                            {
                                list = new List <IFacetAccessible>(m_subBrowsers.Length);
                                mergedMap.Put(name, list);
                            }
                            list.Add(facetAccessor);
                        }
                        facetColMap.Clear();
                    }
                }
            }
            finally
            {
                if (req.MapReduceWrapper != null)
                {
                    req.MapReduceWrapper.FinalizePartition();
                }
                foreach (var entry in mergedMap)
                {
                    string        name    = entry.Key;
                    IFacetHandler handler = GetFacetHandler(name);
                    try
                    {
                        IList <IFacetAccessible> subList = entry.Value;
                        if (subList != null)
                        {
                            IFacetAccessible merged = handler.Merge(req.GetFacetSpec(name), subList);
                            facetMap.Put(name, merged);
                        }
                    }
                    catch (Exception e)
                    {
                        logger.ErrorException(e.Message, e);
                    }
                }
            }
        }