Lucene.Net.Facet.DrillDownQuery.Merge C# (CSharp) Method

Merge() private method

Merges (ORs) a new path into an existing AND'd clause.
private Merge ( string dim, string path ) : void
dim string
path string
return void
        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);
        }