private void merge(String dim, String[] path) {
int index = drillDownDims.get(dim);
if (query.getClauses().length == drillDownDims.size()+1) {
index++;
}
ConstantScoreQuery q = (ConstantScoreQuery) query.clauses().get(index).getQuery();
if ((q.getQuery() instanceof BooleanQuery) == false) {
// App called .add(dim, customQuery) and then tried to
// merge a facet label in:
throw new RuntimeException("cannot merge with custom Query");
}
String indexedField = config.getDimConfig(dim).indexFieldName;
BooleanQuery bq = (BooleanQuery) q.getQuery();
bq.add(new TermQuery(term(indexedField, dim, path)), Occur.SHOULD);
}