Source:
private @NonNull List<Query> computeDisjunctiveFacetingQueries(@NonNull Query query, @NonNull List<String> disjunctiveFacets, @NonNull Map<String, List<String>> refinements) { Map<String, List<String>> disjunctiveRefinements = computeDisjunctiveRefinements(disjunctiveFacets, refinements); List<Query> queries = new ArrayList<>(); JSONArray filters = new JSONArray(); for (Map.Entry<String, List<String>> elt : refinements.entrySet()) { JSONArray or = new JSONArray(); final boolean isDisjunctiveFacet = disjunctiveRefinements.containsKey(elt.getKey()); for (String val : elt.getValue()) { if (isDisjunctiveFacet) { or.put(String.format("%s:%s", elt.getKey(), val)); } else { filters.put(String.format("%s:%s", elt.getKey(), val)); } } if (isDisjunctiveFacet) { filters.put(or); } } queries.add(new Query(query).set("facetFilters", filters)); for (String disjunctiveFacet : disjunctiveFacets) { filters = new JSONArray(); for (Map.Entry<String, List<String>> elt : refinements.entrySet()) { if (disjunctiveFacet.equals(elt.getKey())) { continue; } JSONArray or = new JSONArray(); final boolean isDisjunctiveFacet = disjunctiveRefinements.containsKey(elt.getKey()); for (String val : elt.getValue()) { if (isDisjunctiveFacet) { or.put(String.format("%s:%s", elt.getKey(), val)); } else { filters.put(String.format("%s:%s", elt.getKey(), val)); } } if (isDisjunctiveFacet) { filters.put(or); } } String[] facets = new String[]{disjunctiveFacet}; queries.add(new Query(query).setHitsPerPage(0).setAnalytics(false) .setAttributesToRetrieve().setAttributesToHighlight().setAttributesToSnippet() .setFacets(facets).set("facetFilters", filters.toString())); } return queries; }

Target:
private @NonNull List<Query> computeDisjunctiveFacetingQueries(@NonNull Query query, @NonNull List<String> disjunctiveFacets, @NonNull Map<String, List<String>> refinements) { Map<String, List<String>> disjunctiveRefinements = computeDisjunctiveRefinements(disjunctiveFacets, refinements); List<Query> queries = new ArrayList<>(); JSONArray filters = new JSONArray(); for (Map.Entry<String, List<String>> elt : refinements.entrySet()) { JSONArray or = new JSONArray(); final boolean isDisjunctiveFacet = disjunctiveRefinements.containsKey(elt.getKey()); for (String val : elt.getValue()) { if (isDisjunctiveFacet) { or.put(String.format("%s:%s", elt.getKey(), val)); } else { filters.put(String.format("%s:%s", elt.getKey(), val)); } } if (isDisjunctiveFacet) { filters.put(or); } } queries.add(new Query(query).setFacetFilters(filters)); for (String disjunctiveFacet : disjunctiveFacets) { filters = new JSONArray(); for (Map.Entry<String, List<String>> elt : refinements.entrySet()) { if (disjunctiveFacet.equals(elt.getKey())) { continue; } JSONArray or = new JSONArray(); final boolean isDisjunctiveFacet = disjunctiveRefinements.containsKey(elt.getKey()); for (String val : elt.getValue()) { if (isDisjunctiveFacet) { or.put(String.format("%s:%s", elt.getKey(), val)); } else { filters.put(String.format("%s:%s", elt.getKey(), val)); } } if (isDisjunctiveFacet) { filters.put(or); } } String[] facets = new String[]{disjunctiveFacet}; queries.add(new Query(query).setHitsPerPage(0).setAnalytics(false) .setAttributesToRetrieve().setAttributesToHighlight().setAttributesToSnippet() .setFacets(facets).setFacetFilters(filters)); } return queries; }