Exemplo n.º 1
0
 public FacetTermQuery(BrowseSelection sel, IDictionary <string, float> boostMap, IFacetTermScoringFunctionFactory scoringFactory)
 {
     m_name           = sel.FieldName;
     m_sel            = sel;
     m_scoringFactory = scoringFactory;
     m_boostMap       = boostMap;
 }
        public override FacetCountCollectorSource GetFacetCountCollectorSource(BrowseSelection sel, FacetSpec fspec)
        {
            IEnumerable <string> list = BuildAllRangeStrings(sel.Values);

            // every string in the above list is of the form <latitude, longitude, radius>, which can be interpreted by GeoSimpleFacetCountCollector
            return(new GeoSimpleFacetHandlerFacetCountCollectorSource(_latFacetHandler, _longFacetHandler, _name, fspec, list));
        }
Exemplo n.º 3
0
 public FacetTermQuery(BrowseSelection sel, IDictionary<string, float> boostMap, IFacetTermScoringFunctionFactory scoringFactory)
 {
     _name = sel.FieldName;
     _sel = sel;
     _scoringFactory = scoringFactory;
     _boostMap = boostMap;
 }
        internal PathFacetCountCollector(string name, string sep, BrowseSelection sel, FacetSpec ospec, FacetDataCache dataCache)
        {
            _sel       = sel;
            _ospec     = ospec;
            _name      = name;
            _dataCache = dataCache;
            _sep       = sep;
            _sepArray  = sep.ToCharArray();
            _count     = new LazyBigIntArray(_dataCache.Freqs.Length);
            log.Info(name + ": " + _count.Size());
            _orderArray  = _dataCache.OrderArray;
            _minHitCount = ospec.MinHitCount;
            _maxCount    = ospec.MaxCount;
            if (_maxCount < 1)
            {
                _maxCount = _count.Size();
            }
            FacetSpec.FacetSortSpec sortOption = ospec.OrderBy;
            switch (sortOption)
            {
            case FacetSpec.FacetSortSpec.OrderHitsDesc: _comparatorFactory = new FacetHitcountComparatorFactory(); break;

            case FacetSpec.FacetSortSpec.OrderValueAsc: _comparatorFactory = null; break;

            case FacetSpec.FacetSortSpec.OrderByCustom: _comparatorFactory = ospec.CustomComparatorFactory; break;

            default: throw new ArgumentOutOfRangeException("invalid sort option: " + sortOption);
            }
            _splitPat   = new Regex(_sep, RegexOptions.Compiled);
            _stringData = new string[10];
            _patStart   = 0;
            _patEnd     = 0;
        }
Exemplo n.º 5
0
 public SimpleFacetHandlerFacetCountCollectorSource(Func <BoboIndexReader, FacetDataCache> getFacetData, string name, BrowseSelection sel, FacetSpec ospec)
 {
     this.getFacetData = getFacetData;
     _name             = name;
     _sel   = sel;
     _ospec = ospec;
 }
Exemplo n.º 6
0
 public SimpleGroupByFacetHandlerFacetCountCollectorSource(Func <BoboSegmentReader, FacetDataCache> getFacetData, string name, BrowseSelection sel, FacetSpec ospec)
 {
     this.getFacetData = getFacetData;
     m_name            = name;
     m_sel             = sel;
     m_ospec           = ospec;
 }
Exemplo n.º 7
0
 public MultiValueFacetCountCollectorSource(MultiValueFacetHandler parent, string name, BrowseSelection sel, FacetSpec ospec)
 {
     this._parent = parent;
     this._name   = name;
     this._sel    = sel;
     this._ospec  = ospec;
 }
Exemplo n.º 8
0
 public FacetTermQuery(BrowseSelection sel, Dictionary<string, float> boostMap, IFacetTermScoringFunctionFactory scoringFactory)
 {
     name = sel.FieldName;
     this.sel = sel;
     this.scoringFactory = scoringFactory;
     this.boostMap = boostMap;
 }
Exemplo n.º 9
0
 public CompactMultiValueFacetCountCollectorSource(Func <BoboIndexReader, FacetDataCache> getFacetData, string name, BrowseSelection sel, FacetSpec ospec)
 {
     this.getFacetData = getFacetData;
     _name             = name;
     _ospec            = ospec;
     _sel = sel;
 }
 public GroupbyFacetCountCollectorSource(IEnumerable <SimpleFacetHandler> facetHandlers, string name, string sep, BrowseSelection sel, FacetSpec fspec)
 {
     _facetHandlers = facetHandlers;
     _name          = name;
     _sep           = sep;
     _sel           = sel;
     _fspec         = fspec;
 }
Exemplo n.º 11
0
 public virtual char GetSeparator(BrowseSelection browseSelection)
 {
     if (browseSelection == null || !browseSelection.SelectionProperties.ContainsKey(SEPARATOR_PROP_NAME))
     {
         return separator;
     }
     return browseSelection.SelectionProperties.Get(SEPARATOR_PROP_NAME)[0];
 }
Exemplo n.º 12
0
 public virtual char GetSeparator(BrowseSelection browseSelection)
 {
     if (browseSelection == null || !browseSelection.SelectionProperties.ContainsKey(SEPARATOR_PROP_NAME))
     {
         return(separator);
     }
     return(browseSelection.SelectionProperties.Get(SEPARATOR_PROP_NAME)[0]);
 }
 public virtual int GetFacetsPerKey(BrowseSelection browseSelection)
 {
     if (browseSelection == null || !browseSelection.SelectionProperties.ContainsKey(MAX_FACETS_PER_KEY_PROP_NAME))
     {
         return numFacetsPerKey;
     }
     return int.Parse(browseSelection.SelectionProperties.Get(MAX_FACETS_PER_KEY_PROP_NAME));
 }
Exemplo n.º 14
0
 public virtual int GetFacetsPerKey(BrowseSelection browseSelection)
 {
     if (browseSelection == null || !browseSelection.SelectionProperties.ContainsKey(MAX_FACETS_PER_KEY_PROP_NAME))
     {
         return(numFacetsPerKey);
     }
     return(int.Parse(browseSelection.SelectionProperties.Get(MAX_FACETS_PER_KEY_PROP_NAME)));
 }
        //private int _totalGroups; // NOT USED

        public GroupByFacetCountCollector(string name,
                                          FacetDataCache dataCache,
                                          int docBase,
                                          BrowseSelection sel,
                                          FacetSpec ospec)
            : base(name, dataCache, docBase, sel, ospec)
        {
        }
 public GroupbyFacetCountCollectorSource(IList <SimpleFacetHandler> facetHandlers, string name, string sep, BrowseSelection sel, FacetSpec fspec)
 {
     m_facetHandlers = facetHandlers;
     m_name          = name;
     m_sep           = sep;
     m_sel           = sel;
     m_fspec         = fspec;
 }
Exemplo n.º 17
0
 public BucketFacetCountCollectorSource(string name, BrowseSelection sel, FacetSpec ospec, IDictionary <string, string[]> predefinedBuckets, IFacetHandler dependOnFacetHandler)
 {
     m_name                 = name;
     m_sel                  = sel;
     m_ospec                = ospec;
     m_predefinedBuckets    = predefinedBuckets;
     m_dependOnFacetHandler = dependOnFacetHandler;
 }
        //private int _totalGroups; // NOT USED

        public GroupByFacetCountCollector(string name,
                                    FacetDataCache dataCache,
                                    int docBase,
                                    BrowseSelection sel,
                                    FacetSpec ospec)
            : base(name, dataCache, docBase, sel, ospec)
        {
        }
 public DefaultFacetCountCollector(BrowseSelection sel, FacetDataCache dataCache, string name, FacetSpec ospec)
 {
     _sel = sel;
     _ospec = ospec;
     _name = name;
     _dataCache = dataCache;
     _count = new int[_dataCache.freqs.Length];
     _array = _dataCache.orderArray;
 }
Exemplo n.º 20
0
 public MultiValueFacetCountCollector(string name,
                                      MultiValueFacetDataCache dataCache,
                                      int docBase,
                                      BrowseSelection sel,
                                      FacetSpec ospec)
     : base(name, dataCache, docBase, sel, ospec)
 {
     _array = dataCache.NestedArray;
 }
Exemplo n.º 21
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;
 }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a browser request from the passed in key value pair query string
        /// </summary>
        /// <param name="querystring"></param>
        /// <param name="page"></param>
        /// <param name="useOffset"></param>
        /// <param name="itemsPerPage"></param>
        /// <returns></returns>
        public virtual BrowseRequest CreateBrowseRequest(List <KeyValuePair <string, string> > querystring, int?page = null, bool useOffset = false, int itemsPerPage = 10)
        {
            Query query         = null;
            var   compiledQuery = BuildBaseQuery(querystring);

            if (compiledQuery != null)
            {
                var luceneParams = compiledQuery as LuceneSearchCriteria;
                query = luceneParams?.Query ?? throw new ArgumentException("Provided ISearchCriteria dos not match the allowed ISearchCriteria. Ensure you only use an ISearchCriteria created from the current SearcherProvider");
            }

            var offset = 0;

            if (!page.HasValue)
            {
                page = 1;
            }
            var count = page.Value * itemsPerPage;

            if (useOffset)
            {
                offset = (page.Value - 1) * itemsPerPage;
                count  = itemsPerPage;
            }

            var browseRequest = new BrowseRequest
            {
                Offset            = offset,
                Count             = count,
                Query             = query,
                FetchStoredFields = true,
                Sort = DetermineSort(querystring)
            };

            var facetSelection = QueryStringParser.ParseQueryString(querystring, FacetFields);

            foreach (var facetField in facetSelection)
            {
                if (facetField.Value.Any())
                {
                    var sel = new BrowseSelection(facetField.Key.Alias.FacetFieldAlias());
                    foreach (var selection in facetField.Value)
                    {
                        if (!string.IsNullOrEmpty(selection))
                        {
                            sel.AddValue(selection);
                        }
                    }
                    sel.SelectionOperation = facetField.Key.SelectionOperation;
                    browseRequest.AddSelection(sel);
                }
            }

            return(browseRequest);
        }
Exemplo n.º 23
0
        public void TestLogging()
        {
            // Set up a simple Log4Net configuration that logs in memory.
            var memAppend = new log4net.Appender.MemoryAppender();

#if NETCOREAPP1_0
            var repository = LogManager.GetRepository(Assembly.GetEntryAssembly());
            BasicConfigurator.Configure(repository, memAppend);
#else
            BasicConfigurator.Configure(memAppend);
#endif

            BrowseRequest br = new BrowseRequest();
            br.Count  = 20;
            br.Offset = 0;

            BrowseSelection colorSel = new BrowseSelection("mycolor");
            colorSel.AddValue("yellow");
            br.AddSelection(colorSel);

            BrowseSelection makeSel = new BrowseSelection("make");
            makeSel.AddValue("rav4");
            br.AddSelection(makeSel);

            FacetSpec spec = new FacetSpec();
            spec.ExpandSelection = true;
            spec.OrderBy         = FacetSpec.FacetSortSpec.OrderHitsDesc;
            spec.MaxCount        = 15;

            br.SetFacetSpec("mycolor", spec);
            br.SetFacetSpec("id", spec);
            br.SetFacetSpec("make", spec);

            Directory ramIndexDir = CreateIndex();
            using (DirectoryReader srcReader = DirectoryReader.Open(ramIndexDir))
            {
                using (BoboMultiReader boboReader = BoboMultiReader.GetInstance(srcReader, _facetHandlers))
                {
                    using (BoboBrowser boboBrowser = new BoboBrowser(boboReader))
                    {
                        using (BrowseResult result = boboBrowser.Browse(br))
                        {
                        }
                    }
                }
            }

            var events = memAppend.GetEvents();

            Assert.AreEqual(3, events.Length);
            StringAssert.StartsWith("facetHandler loaded: id, took:", events[0].RenderedMessage);
            StringAssert.StartsWith("facetHandler loaded: make, took:", events[1].RenderedMessage);
            StringAssert.StartsWith("facetHandler loaded: mycolor, took:", events[2].RenderedMessage);
        }
Exemplo n.º 24
0
 public override FacetCountCollectorSource GetFacetCountCollectorSource(BrowseSelection sel, FacetSpec ospec, bool groupMode)
 {
     if (groupMode)
     {
         return(new SimpleGroupByFacetHandlerFacetCountCollectorSource(this.GetFacetData <FacetDataCache>, _name, sel, ospec));
     }
     else
     {
         return(new SimpleFacetHandlerFacetCountCollectorSource(this.GetFacetData <FacetDataCache>, _name, sel, ospec));
     }
 }
 public AttributesFacetCountCollector(AttributesFacetHandler attributesFacetHandler, string name, MultiValueFacetDataCache dataCache, int docBase, BrowseSelection browseSelection, FacetSpec ospec, int numFacetsPerKey, char separator)
     : base(name, dataCache, docBase, browseSelection, ospec)
 {
     this.attributesFacetHandler = attributesFacetHandler;
     this.dataCache = dataCache;
     this.numFacetsPerKey = numFacetsPerKey;
     this.separator = separator;
     //_array = dataCache.NestedArray; // NOT USED
     if (browseSelection != null)
     {
         values = browseSelection.Values;
     }
 }
Exemplo n.º 26
0
        BrowseSelection IContentHandler.GetSelection(ResourceSearchQuery searchQuery)
        {
            if (searchQuery.ResourceType == null)
            {
                return(null);
            }

            var selection = new BrowseSelection(FieldName.ItemType);

            selection.addValue(searchQuery.ResourceType.Value.Encode());

            return(selection);
        }
        public override RandomAccessFilter BuildRandomAccessFilter(string value, IDictionary <string, string> selectionProperty)
        {
            List <RandomAccessFilter> filterList = new List <RandomAccessFilter>();

            string[] vals = value.Split(new string[] { m_sep }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < vals.Length; ++i)
            {
                SimpleFacetHandler handler = m_facetHandlers[i];
                BrowseSelection    sel     = new BrowseSelection(handler.Name);
                sel.AddValue(vals[i]);
                filterList.Add(handler.BuildFilter(sel));
            }
            return(new RandomAccessAndFilter(filterList));
        }
Exemplo n.º 28
0
        public void TestNotValuesForSimpleFacetHandler()
        {
            BrowseRequest br = new BrowseRequest();

            br.Count  = 20;
            br.Offset = 0;

            BrowseSelection colorSel = new BrowseSelection("color");

            colorSel.AddValue("red");
            br.AddSelection(colorSel);

            BrowseSelection idSel = new BrowseSelection("id");

            idSel.AddNotValue("0");
            br.AddSelection(idSel);

            BrowseResult result         = null;
            BoboBrowser  boboBrowser    = null;
            int          expectedHitNum = (_documentSize / 2) - 1;

            using (Directory ramIndexDir = CreateIndex())
            {
                using (IndexReader srcReader = IndexReader.Open(ramIndexDir, true))
                {
                    using (boboBrowser = new BoboBrowser(BoboIndexReader.GetInstance(srcReader, _facetHandlers, null)))
                    {
                        result = boboBrowser.Browse(br);

                        Assert.AreEqual(expectedHitNum, result.NumHits);

                        StringBuilder buffer = new StringBuilder();
                        BrowseHit[]   hits   = result.Hits;

                        for (int i = 0; i < hits.Length; ++i)
                        {
                            int expectedID = (i + 1) * 2;
                            Assert.AreEqual(expectedID, int.Parse(hits[i].GetField("id")));
                            if (i != 0)
                            {
                                buffer.Append('\n');
                            }
                            buffer.Append("id=" + hits[i].GetField("id") + "," + "color=" + hits[i].GetField("color"));
                        }
                        log.Info(buffer.ToString());
                    }
                }
            }
        }
 public void AddSelection(string name, string val, bool isNot)
 {
     BrowseSelection sel = _req.GetSelection(name);
     if (sel == null)
     {
         sel = new BrowseSelection(name);
     }
     if (isNot)
     {
         sel.AddNotValue(val);
     }
     else
     {
         sel.AddValue(val);
     }
     _req.AddSelection(sel);
 }
Exemplo n.º 30
0
        public virtual RandomAccessFilter BuildFilter(BrowseSelection sel)
        {
            string[] selections               = sel.Values;
            string[] notSelections            = sel.NotValues;
            IDictionary <string, string> prop = sel.SelectionProperties;

            RandomAccessFilter filter = null;

            if (selections != null && selections.Length > 0)
            {
                if (sel.SelectionOperation == BrowseSelection.ValueOperation.ValueOperationAnd)
                {
                    filter = BuildRandomAccessAndFilter(selections, prop);
                    if (filter == null)
                    {
                        filter = EmptyFilter.Instance;
                    }
                }
                else
                {
                    filter = BuildRandomAccessOrFilter(selections, prop, false);
                    if (filter == null)
                    {
                        return(EmptyFilter.Instance);
                    }
                }
            }

            if (notSelections != null && notSelections.Length > 0)
            {
                RandomAccessFilter notFilter = BuildRandomAccessOrFilter(notSelections, prop, true);
                if (filter == null)
                {
                    filter = notFilter;
                }
                else
                {
                    RandomAccessFilter andFilter =
                        new RandomAccessAndFilter(new RandomAccessFilter[] { filter, notFilter }.ToList());
                    filter = andFilter;
                }
            }

            return(filter);
        }
Exemplo n.º 31
0
        public void TestFacetNameForSimpleFacetHandler()
        {
            BrowseRequest br = new BrowseRequest();

            br.Count  = 20;
            br.Offset = 0;

            BrowseSelection colorSel = new BrowseSelection("mycolor");

            colorSel.AddValue("yellow");
            br.AddSelection(colorSel);

            BrowseSelection makeSel = new BrowseSelection("make");

            makeSel.AddValue("rav4");
            br.AddSelection(makeSel);

            FacetSpec spec = new FacetSpec();

            spec.ExpandSelection = true;
            spec.OrderBy         = FacetSpec.FacetSortSpec.OrderHitsDesc;
            spec.MaxCount        = 15;

            br.SetFacetSpec("mycolor", spec);
            br.SetFacetSpec("id", spec);
            br.SetFacetSpec("make", spec);

            int expectedHitNum = 3;

            Directory ramIndexDir = CreateIndex();

            using (DirectoryReader srcReader = DirectoryReader.Open(ramIndexDir))
            {
                using (BoboMultiReader boboReader = BoboMultiReader.GetInstance(srcReader, _facetHandlers))
                {
                    using (BoboBrowser boboBrowser = new BoboBrowser(boboReader))
                    {
                        using (BrowseResult result = boboBrowser.Browse(br))
                        {
                            Assert.AreEqual(expectedHitNum, result.NumHits);
                        }
                    }
                }
            }
        }
        public BrowseRequest CreateRequest(int minHitCount, BrowseSelection.ValueOperation operation, params string[] terms)
        {
            BrowseRequest req = new BrowseRequest();

            BrowseSelection sel = new BrowseSelection(AttributeHandlerName);
            foreach (String term in terms)
            {
                sel.AddValue(term);
            }
            sel.SetSelectionProperties(selectionProperties);
            sel.SelectionOperation = (operation);
            req.AddSelection(sel);
            req.Count = (50);
            FacetSpec fs = new FacetSpec();
            fs.MinHitCount = (minHitCount);
            req.SetFacetSpec(AttributeHandlerName, fs);
            return req;
        }
Exemplo n.º 33
0
        protected BrowseSelection GetSelection(ICollection <Guid> industryIds)
        {
            if (industryIds == null || industryIds.Count == 0 || _allIndustryIds.IsSubsetOf(industryIds))
            {
                return(null);
            }

            var selection = new BrowseSelection(_fieldName);

            selection.setSelectionOperation(BrowseSelection.ValueOperation.ValueOperationOr);

            foreach (var industry in industryIds.Select(id => id.ToFieldValue()))
            {
                selection.addValue(industry);
            }

            return(selection);
        }
Exemplo n.º 34
0
        BrowseSelection IContentHandler.GetSelection(MemberSearchQuery searchQuery)
        {
            if (searchQuery.CandidateStatusList == null || _allStatuses.IsSubsetOf(searchQuery.CandidateStatusList))
            {
                return(null);
            }

            var selection = new BrowseSelection(FieldName.CandidateStatus);

            selection.setSelectionOperation(BrowseSelection.ValueOperation.ValueOperationOr);

            foreach (var status in searchQuery.CandidateStatusList)
            {
                selection.addValue(status.Encode());
            }

            return(selection);
        }
        public void AddSelection(string name, string val, bool isNot)
        {
            BrowseSelection sel = m_req.GetSelection(name);

            if (sel == null)
            {
                sel = new BrowseSelection(name);
            }
            if (isNot)
            {
                sel.AddNotValue(val);
            }
            else
            {
                sel.AddValue(val);
            }
            m_req.AddSelection(sel);
        }
Exemplo n.º 36
0
        protected BrowseSelection GetSelection(JobTypes?jobTypes)
        {
            if (!jobTypes.HasValue || jobTypes.Value == JobTypes.None || jobTypes.Value == JobTypes.All)
            {
                return(null);
            }

            var selection = new BrowseSelection(_fieldName);

            selection.setSelectionOperation(BrowseSelection.ValueOperation.ValueOperationOr);

            foreach (var jobType in Split(jobTypes.Value))
            {
                selection.addValue(Encode(jobType));
            }

            return(selection);
        }
Exemplo n.º 37
0
        public BrowseRequest CreateRequest(int minHitCount, BrowseSelection.ValueOperation operation, params string[] terms)
        {
            BrowseRequest req = new BrowseRequest();

            BrowseSelection sel = new BrowseSelection(AttributeHandlerName);

            foreach (String term in terms)
            {
                sel.AddValue(term);
            }
            sel.SetSelectionProperties(selectionProperties);
            sel.SelectionOperation = (operation);
            req.AddSelection(sel);
            req.Count = (50);
            FacetSpec fs = new FacetSpec();

            fs.MinHitCount = (minHitCount);
            req.SetFacetSpec(AttributeHandlerName, fs);
            return(req);
        }
Exemplo n.º 38
0
        public void TestNotValuesForRangeFacetHandler()
        {
            Console.WriteLine("TestNotValuesForRangeFacetHandler");
            BrowseResult result      = null;
            BoboBrowser  boboBrowser = null;

            using (Directory ramIndexDir = CreateIndexTwo())
            {
                using (IndexReader srcReader = IndexReader.Open(ramIndexDir, true))
                {
                    using (boboBrowser = new BoboBrowser(BoboIndexReader.GetInstance(srcReader, _facetHandlers, null)))
                    {
                        BrowseRequest br = new BrowseRequest();
                        br.Count  = (20);
                        br.Offset = (0);

                        if (_idRanges == null)
                        {
                            log.Error("_idRanges cannot be null in order to test NOT on RangeFacetHandler");
                        }
                        BrowseSelection idSel = new BrowseSelection("idRange");
                        //int rangeIndex = 2; // Not used
                        idSel.AddNotValue(_idRanges[0]);
                        int expectedHitNum = 1;
                        br.AddSelection(idSel);
                        BooleanQuery q = new BooleanQuery();
                        q.Add(NumericRangeQuery.NewIntRange("NUM", 10, 10, true, true), Occur.MUST_NOT);
                        q.Add(new MatchAllDocsQuery(), Occur.MUST);
                        br.Query = q;

                        result = boboBrowser.Browse(br);

                        Assert.AreEqual(expectedHitNum, result.NumHits);
                        for (int i = 0; i < result.NumHits; i++)
                        {
                            Console.WriteLine(result.Hits[i]);
                        }
                    }
                }
            }
        }
        internal PathFacetCountCollector(string name, string sep, BrowseSelection sel, FacetSpec ospec, FacetDataCache dataCache)
        {
            m_sel       = sel;
            m_name      = name;
            m_dataCache = dataCache;
            m_sep       = sep;
            m_sepArray  = sep.ToCharArray();
            m_count     = new LazyBigInt32Array(m_dataCache.Freqs.Length);
            log.Info(name + ": " + m_count.Length);
            m_orderArray  = m_dataCache.OrderArray;
            m_minHitCount = ospec.MinHitCount;
            m_maxCount    = ospec.MaxCount;
            if (m_maxCount < 1)
            {
                m_maxCount = m_count.Length;
            }
            FacetSpec.FacetSortSpec sortOption = ospec.OrderBy;
            switch (sortOption)
            {
            case FacetSpec.FacetSortSpec.OrderHitsDesc:
                m_comparerFactory = new FacetHitcountComparerFactory();
                break;

            case FacetSpec.FacetSortSpec.OrderValueAsc:
                m_comparerFactory = null;
                break;

            case FacetSpec.FacetSortSpec.OrderByCustom:
                m_comparerFactory = ospec.CustomComparerFactory;
                break;

            default:
                throw new ArgumentOutOfRangeException("invalid sort option: " + sortOption);
            }
            // Doesn't make much sense to do this, so it is commented.
            // new Regex(_sep, RegexOptions.Compiled);
            m_stringData = new string[10];
            m_patStart   = 0;
            m_patEnd     = 0;
        }
        public DefaultFacetCountCollector(string name, FacetDataCache dataCache, int docBase, BrowseSelection sel, FacetSpec ospec)
        {
            _sel = sel;
            _ospec = ospec;
            _name = name;
            _dataCache = dataCache;
            _countlength = _dataCache.Freqs.Length;

            if (_dataCache.Freqs.Length <= 3096)
            {
                _count = new LazyBigIntArray(_countlength);
            }
            else
            {
                _count = new LazyBigIntArray(_countlength);

                // NOTE: Removed memory manager implementation
                //_count = intarraymgr.Get(_countlength);
                //intarraylist.Add(_count);
            }

            _array = _dataCache.OrderArray;
            _docBase = docBase;
        }
        private BrowseResult PerformSearch(Query query, string indexPath, IEnumerable<Models.SelectionGroup> selectionGroups)
        {
            string[] FieldNames = new string[] { "Material", "Style", "Mounting", "Brand" };

            var handlers = new List<FacetHandler>();

            foreach (string field in FieldNames)
            {
                handlers.Add(new SimpleFacetHandler(field));
            }

            // Run the search

            // create the index reader
            var directory = FSDirectory.Open(new System.IO.DirectoryInfo(indexPath));
            var indexReader = DirectoryReader.Open(directory, true);

            //// This is how to get a searcher for executing the search, not for working with facets
            //IndexSearcher indexSearcher = new IndexSearcher(directory, true);
            //indexSearcher.Search(

            // Decorate it with the Bobo index reader
            BoboIndexReader boboReader = BoboIndexReader.GetInstance(indexReader, handlers);

            // create a browse request
            BrowseRequest browseRequest = new BrowseRequest();

            // NOTE: these must be used in production to page the results
            browseRequest.Count = 50;
            browseRequest.Offset = 0;

            browseRequest.FetchStoredFields = true;

            //Query query = new QueryParser(
            //        Lucene.Net.Util.Version.LUCENE_29,
            //        "title",
            //        new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)
            //    ).Parse(model.Phrase);

            if (selectionGroups != null)
            {
                // Add the selections to the search

                foreach (var group in selectionGroups)
                {
                    BrowseSelection sel = new BrowseSelection(group.Name);
                    foreach (var value in group.Selections)
                    {
                        sel.AddValue(value);
                    }
                    browseRequest.AddSelection(sel);
                }

            }

            browseRequest.Query = query;

            //// add the facet output specs
            //FacetSpec brandSpec = new FacetSpec();
            //brandSpec.OrderBy = FacetSpec.FacetSortSpec.OrderHitsDesc;

            //browseRequest.SetFacetSpec("Brand", brandSpec);

            foreach (var name in FieldNames)
            {
                // add the facet output specs
                FacetSpec spec = new FacetSpec();
                //spec.OrderBy = FacetSpec.FacetSortSpec.OrderHitsDesc;

                // NOTE: if this is a secondary search, we want to get the facets with 0
                // hits so the checkboxes can be set on the UI...or otherwise program the UI
                // to disable and set to 0 all of the selections that aren't in the result
                if (selectionGroups != null)
                {
                    spec.MinHitCount = 0;
                }

                browseRequest.SetFacetSpec(name, spec);
            }

            // perform browse
            IBrowsable browser = new BoboBrowser(boboReader);

            BrowseResult result = browser.Browse(browseRequest);

            return result;
        }
        private BrowseResult PerformAutoCompleteLookup(string prefix, string indexPath)
        {
            FacetHandler handler = new MultiValueFacetHandler("title");

            Directory directory = FSDirectory.Open(new System.IO.DirectoryInfo(indexPath));
            IndexReader indexReader = IndexReader.Open(directory, true);

            // decorate it with a bobo index reader
            BoboIndexReader boboReader = BoboIndexReader.GetInstance(indexReader, new FacetHandler[] { handler });

            BrowseRequest browseRequest = new BrowseRequest();
            browseRequest.Count = 8;
            browseRequest.Offset = 0;
            browseRequest.FetchStoredFields = true;

            // add a selection
            BrowseSelection sel = new BrowseSelection("title");
            //sel.AddValue("alexey");
            browseRequest.AddSelection(sel);

            // parse a query
            // NOTE: this was "Entity" originally
            QueryParser parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "title", new KeywordAnalyzer());
            Query q = parser.Parse("SPListItem");
            browseRequest.Query = q;

            // add the facet output specs
            FacetSpec spec = new FacetSpec();
            spec.Prefix = prefix;
            spec.OrderBy = FacetSpec.FacetSortSpec.OrderHitsDesc;

            browseRequest.SetFacetSpec("title", spec);

            // perform browse
            IBrowsable browser = new BoboBrowser(boboReader);

            BrowseResult result = browser.Browse(browseRequest);

            return result;

            //// Showing results now
            //Dictionary<String, IFacetAccessible> facetMap = result.FacetMap;

            //IFacetAccessible colorFacets = facetMap["Body"];

            //IEnumerable<BrowseFacet> facetVals = colorFacets.GetFacets();

            //Debug.WriteLine("Facets:");

            //int count = 0;
            //foreach (BrowseFacet facet in facetVals)
            //{
            //    count++;
            //    Debug.WriteLine(facet.ToString());
            //}
            //Debug.WriteLine("Total = " + count);
        }
 public SimpleFacetCountCollector(BrowseSelection sel, FacetDataCache dataCache, string name, FacetSpec ospec)
     : base(sel, dataCache, name, ospec)
 {
 }
 public override IFacetCountCollector GetFacetCountCollector(BrowseSelection sel, FacetSpec ospec)
 {
     return new SimpleFacetCountCollector(sel, _dataCache, this.Name, ospec);
 }
 public override IFacetCountCollector GetFacetCountCollector(BrowseSelection sel, FacetSpec fspec)
 {
     return new FilterMapFacetCountCollector(this);
 }
 public MultiValuedPathFacetCountCollector(string name, string sep,
     BrowseSelection sel, FacetSpec ospec, FacetDataCache dataCache)
     : base(name, sep, sel, ospec, dataCache)
 {
     _array = ((MultiValueFacetDataCache)(dataCache)).NestedArray;
 }
Exemplo n.º 47
0
 public override IFacetCountCollector GetFacetCountCollector(BrowseSelection sel, FacetSpec ospec)
 {
     return new PathFacetCountCollector(this.Name, separator, sel, ospec, dataCache);
 }
Exemplo n.º 48
0
 internal PathFacetCountCollector(string name, string sep, BrowseSelection sel, FacetSpec ospec, FacetDataCache dataCache)
 {
     _sel = sel;
     _ospec = ospec;
     _name = name;
     _dataCache = dataCache;
     _sep = sep;
     _count = new int[_dataCache.freqs.Length];
     _orderArray = _dataCache.orderArray;
 }
Exemplo n.º 49
0
 public AttributesFacetCountCollectorSource(AttributesFacetHandler parent, BrowseSelection browseSelection, FacetSpec ospec)
 {
     _parent = parent;
     _browseSelection = browseSelection;
     _ospec = ospec;
 }
Exemplo n.º 50
0
 /// <summary>
  /// Gets a FacetCountCollector 
 /// </summary>
 /// <param name="sel"></param>
 /// <param name="fspec"></param>
 /// <returns></returns>
  public abstract IFacetCountCollector GetFacetCountCollector(BrowseSelection sel, FacetSpec fspec);
 public override IFacetCountCollector GetFacetCountCollector(BrowseSelection sel, FacetSpec ospec)
 {
     return new RangeFacetCountCollector(this.Name, dataCache, ospec, predefinedRanges, autoRange);
 }
Exemplo n.º 52
0
        public RandomAccessFilter BuildFilter(BrowseSelection sel)
        {
            string[] selections = sel.Values;
            string[] notSelections = sel.NotValues;
            Properties prop = sel.SelectionProperties;

            RandomAccessFilter filter = null;
            if (selections != null && selections.Length > 0)
            {
                if (sel.SelectionOperation == BrowseSelection.ValueOperation.ValueOperationAnd)
                {
                    filter = BuildRandomAccessAndFilter(selections, prop);
                    if (filter == null)
                    {
                        filter = EmptyFilter.GetInstance();
                    }
                }
                else
                {
                    filter = BuildRandomAccessOrFilter(selections, prop, false);
                    if (filter == null)
                    {
                        return EmptyFilter.GetInstance();
                    }
                }
            }

            if (notSelections != null && notSelections.Length > 0)
            {
                RandomAccessFilter notFilter = BuildRandomAccessOrFilter(notSelections, prop, true);
                if (filter == null)
                {
                    filter = notFilter;
                }
                else
                {
                    RandomAccessFilter andFilter =
                        new RandomAccessAndFilter(new RandomAccessFilter[] { filter, notFilter }.ToList());
                    filter = andFilter;
                }
            }

            return filter;
        }
 internal MultiValueFacetCountCollector(BrowseSelection sel, FacetDataCache dataCache, string name, FacetSpec ospec)
     : base(sel, dataCache, name, ospec)
 {
     _array = ((MultiValueFacetDataCache)(_dataCache))._nestedArray;
 }
Exemplo n.º 54
0
 public override FacetCountCollectorSource GetFacetCountCollectorSource(BrowseSelection sel, FacetSpec ospec)
 {
     return new AttributesFacetCountCollectorSource(this, sel, ospec);
 }
Exemplo n.º 55
0
 public FacetTermQuery(BrowseSelection sel, IDictionary<string, float> boostMap)
     : this(sel, boostMap, new DefaultFacetTermScoringFunctionFactory())
 {
 }