19 using System.Collections.Generic;
22 using Lucene.Net.Analysis;
23 using Lucene.Net.Documents;
24 using Lucene.Net.Analysis.Standard;
25 using Lucene.Net.Index;
26 using Lucene.Net.Search;
27 using Lucene.Net.QueryParsers;
28 using Lucene.Net.Store;
29 using Lucene.Net.Util;
30 using System.Threading;
33 using System.Threading.Tasks;
60 namespace Lucene.Net.Search
64 public const int DefaultMaxDocPerGroup = 25;
65 public static int MAX_FACETS = 2048;
76 this._Reader = reader;
78 List<FieldValuesBitSets> fieldValuesBitSets =
new List<FieldValuesBitSets>();
85 IList<IList<string>> inputToCP =
new List<IList<string>>();
86 foreach (
string field
in groupByFields)
90 if (maxFacets > MAX_FACETS)
throw new Exception(
"Facet count exceeded " + MAX_FACETS);
91 fieldValuesBitSets.Add(f);
98 var cp = inputToCP.CartesianProduct();
106 Parallel.ForEach(cp, combinations =>
108 foreach(var combinations in cp)
113 List<string> comb = combinations.ToList();
115 for (
int j = 0; j < comb.Count; j++)
117 bitSet.
And(fieldValuesBitSets[j].FieldValueBitSetPair[comb[j]]);
124 _Groups.Add(
new KeyValuePair<List<string>,
OpenBitSetDISI>(comb, bitSet));
137 return Search(query, DefaultMaxDocPerGroup);
142 var hitsPerGroup =
new List<HitsPerFacet>();
145 var actions =
new Action[_Groups.Count];
146 for (
int i = 0; i < _Groups.Count; i++)
148 var h =
new HitsPerFacet(
new FacetName(_Groups[i].Key.ToArray()), _Reader, queryDocidSet, _Groups[i].Value, maxDocPerGroup);
150 actions[i] = h.Calculate;
154 Parallel.Invoke(actions);
156 foreach (var action
in actions)
165 public void Dispose()