예제 #1
0
 public PathFacetHandlerFacetCountCollectorSource(PathFacetHandler parent, string name, string separator, BrowseSelection sel, FacetSpec ospec, bool multiValue)
 {
     _parent     = parent;
     _name       = name;
     _separator  = separator;
     _sel        = sel;
     _ospec      = ospec;
     _multiValue = multiValue;
 }
예제 #2
0
        public void Init()
        {
            facetHandlers = new List<IFacetHandler>();

            directory = new RAMDirectory();
            analyzer = new WhitespaceAnalyzer();
            IndexWriter writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
            Document doc = new Document();
            AddMetaDataField(doc, PathHandlerName, new String[] { "/a/b/c", "/a/b/d" });
            writer.AddDocument(doc);
            writer.Commit();

            PathFacetHandler pathHandler = new PathFacetHandler("path", true);
            facetHandlers.Add(pathHandler);
        }
        public virtual FacetIterator GetIterator()
        {
            IDictionary <string, string> props = m_sel == null ? null : m_sel.SelectionProperties;
            int  depth  = PathFacetHandler.GetDepth(props);
            bool strict = PathFacetHandler.IsStrict(props);
            List <BrowseFacet> finalList;

            string[] paths = m_sel == null ? null : m_sel.Values;
            if (paths == null || paths.Length == 0)
            {
                finalList = new List <BrowseFacet>(GetFacetsForPath(null, depth, strict, int.MinValue, m_count.Length));
                return(new PathFacetIterator(finalList));
            }

            if (paths.Length == 1)
            {
                finalList = new List <BrowseFacet>(GetFacetsForPath(paths[0], depth, strict, int.MinValue, m_count.Length));
                return(new PathFacetIterator(finalList));
            }

            finalList = new List <BrowseFacet>();
            var iterList = new List <IEnumerator <BrowseFacet> >(paths.Length);

            foreach (string path in paths)
            {
                var subList = GetFacetsForPath(path, depth, strict, int.MinValue, m_count.Length);
                if (subList.Count > 0)
                {
                    iterList.Add(subList.GetEnumerator());
                }
            }
            var finalIter = ListMerger.MergeLists(iterList.ToArray(),
                                                  m_comparerFactory == null ? new FacetValueComparerFactory().NewComparer() : m_comparerFactory.NewComparer());

            while (finalIter.MoveNext())
            {
                BrowseFacet f = finalIter.Current;
                finalList.Add(f);
            }
            return(new PathFacetIterator(finalList));
        }
        public virtual IEnumerable <BrowseFacet> GetFacets()
        {
            IDictionary <string, string> props = _sel == null ? null : _sel.SelectionProperties;
            int  depth  = PathFacetHandler.GetDepth(props);
            bool strict = PathFacetHandler.IsStrict(props);

            string[] paths = _sel == null ? null : _sel.Values;
            if (paths == null || paths.Length == 0)
            {
                return(GetFacetsForPath(null, depth, strict, _minHitCount, _maxCount));
            }

            if (paths.Length == 1)
            {
                return(GetFacetsForPath(paths[0], depth, strict, _minHitCount, _maxCount));
            }

            List <BrowseFacet> finalList = new List <BrowseFacet>();
            var iterList = new List <IEnumerator <BrowseFacet> >(paths.Length);

            foreach (string path in paths)
            {
                var subList = GetFacetsForPath(path, depth, strict, _minHitCount, _maxCount);
                if (subList.Count() > 0)
                {
                    iterList.Add(subList.GetEnumerator());
                }
            }

            var finalIter = ListMerger.MergeLists(iterList.ToArray(),
                                                  _comparatorFactory == null ? new FacetValueComparatorFactory().NewComparator() : _comparatorFactory.NewComparator());

            while (finalIter.MoveNext())
            {
                BrowseFacet f = finalIter.Current;
                finalList.Insert(0, f);
            }
            return(finalList);
        }