Exemple #1
0
        public static Dictionary <string, int> Facet(Query query, IndexSearcher s, string field)
        {
            StringIndex stringIndex = FieldCache_Fields.DEFAULT.GetStringIndex(s.GetIndexReader(), field);

            int[] array = new int[stringIndex.lookup.Length];
            SimpleFacets.FacetCollector results = new SimpleFacets.FacetCollector(array, stringIndex);
            s.Search(query, results);
            SimpleFacets.DictionaryEntryQueue dictionaryEntryQueue = new SimpleFacets.DictionaryEntryQueue(stringIndex.lookup.Length);
            for (int i = 1; i < stringIndex.lookup.Length; i++)
            {
                if (array[i] > 0 && stringIndex.lookup[i] != null && stringIndex.lookup[i] != "0")
                {
                    dictionaryEntryQueue.Insert(new SimpleFacets.FacetEntry(stringIndex.lookup[i], -array[i]));
                }
            }
            int num = dictionaryEntryQueue.Size();
            Dictionary <string, int> dictionary = new Dictionary <string, int>();

            for (int j = num - 1; j >= 0; j--)
            {
                SimpleFacets.FacetEntry facetEntry = dictionaryEntryQueue.Pop() as SimpleFacets.FacetEntry;
                dictionary.Add(facetEntry.Value, -facetEntry.Count);
            }
            return(dictionary);
        }
        public static Dictionary <string, int> Facet(Query query, IndexSearcher s, string field)
        {
            StringIndex stringIndex = FieldCache_Fields.DEFAULT.GetStringIndex(s.GetIndexReader(), field);

            int[] c = new int[stringIndex.lookup.Length];
            SimpleFacets.FacetCollector facetCollector = new SimpleFacets.FacetCollector(c, stringIndex);
            s.Search(query, (HitCollector)facetCollector);
            SimpleFacets.DictionaryEntryQueue dictionaryEntryQueue = new SimpleFacets.DictionaryEntryQueue(stringIndex.lookup.Length);
            for (int index = 1; index < stringIndex.lookup.Length; ++index)
            {
                if (c[index] > 0 && stringIndex.lookup[index] != null && stringIndex.lookup[index] != "0")
                {
                    dictionaryEntryQueue.Insert((object)new SimpleFacets.FacetEntry(stringIndex.lookup[index], -c[index]));
                }
            }
            int num = dictionaryEntryQueue.Size();
            Dictionary <string, int> dictionary = new Dictionary <string, int>();

            for (int index = num - 1; index >= 0; --index)
            {
                SimpleFacets.FacetEntry facetEntry = dictionaryEntryQueue.Pop() as SimpleFacets.FacetEntry;
                dictionary.Add(facetEntry.Value, -facetEntry.Count);
            }
            return(dictionary);
        }