private void Merge(string dim, string[] path)
{
int index = 0;
int? idx;
if (drillDownDims.TryGetValue(dim, out idx) && idx.HasValue)
{
index = idx.Value;
}
if (query.Clauses.Length == drillDownDims.Count + 1)
{
index++;
}
ConstantScoreQuery q = (ConstantScoreQuery)query.Clauses[index].Query;
if ((q.Query is BooleanQuery) == false)
{
// App called .add(dim, customQuery) and then tried to
// merge a facet label in:
throw new Exception("cannot merge with custom Query");
}
string indexedField = config.GetDimConfig(dim).IndexFieldName;
BooleanQuery bq = (BooleanQuery)q.Query;
bq.Add(new TermQuery(Term(indexedField, dim, path)), Occur.SHOULD);
}