How to pass multiple facets in a single query

Hi There,

I am trying to pass 2 or more facets in a single query.
For that, I am doing something like this:
var selectedFacet ="";
var programFilter="";

searchPrograms.helper.addFacetRefinement(“Highlights.Credential”, “Certificate”);
searchPrograms.helper.addFacetRefinement(“Highlights.Credential”, “Diploma”);

searchPrograms.helper.search();

selectedFacet=“AND Highlights.Credential:” + “”" + “Certificate” + “”";
selectedFacet +=" “+ “AND Highlights.Credential:” + “”” + “Certificate (Non-Credit)” + “”";

programFilter += " " +selectedFacet;

searchPrograms.helper.setQueryParameter(‘filters’, programFilter);

my query results in:

“Schema: “SchemaName” AND Highlights.Credential:“Certificate” AND Highlights.Credential:“Certificate (Non-Credit)”” . This gives me 0 results. If I try to add only a single facet refinement, it works fine, but I want to combine two facets in a single query and I am failing to do so.

Please Suggest how to resolve this.

Thank You
Deepika

I have figured out the right way to do it. I need to use addDisjunctiveFacetRefinements here instead of addFacetRefinements.

var selectedFacet ="";
var programFilter="";

searchPrograms.helper.addDisjunctiveFacetRefinement(“Highlights.Credential”, “Certificate”);
searchPrograms.helper.addDisjunctiveFacetRefinement(“Highlights.Credential”, “Diploma”);

searchPrograms.helper.search();

selectedCredentialFacet = “AND (Highlights.Credential:” + “”" + “Certificate” + “”" + " OR Highlights.Credential:" + “”" + “Diploma” + “”" + “)”;

programFilter += " " +selectedFacet;

searchPrograms.helper.setQueryParameter(‘filters’, programFilter);

Now, this gives me results from both facets.

Thank You

Glad to hear it is working for you!