Skip to Content
0
Jul 24, 2019 at 01:03 PM

Building SOLR filter query with the OR operator in SearchFilterQueryData

2013 Views

Hi Experts,

During the search in the CategoryPageController I am trying to modify the SOLR query and add some filter parameters (about 4 filter params) and example like this:

 final SearchFilterQueryData searchNameFilterQuery = new SearchFilterQueryData();
 searchNameFilterQuery.setKey("name");
 searchNameFilterQuery.setValues(new HashSet<> 
   (Collections.singletonList(queryData.get("name"))));
 searchNameFilterQuery.setOperator(FilterQueryOperator.OR);

and add it to the this.searchQueryData.setFilterQueries list.

Now in the query being formed,

yq=:&q={!boost}(%2B{!lucene+v%3D$yq})&fq=allCategories_string_mv:1 &fq=gskProductAvailability_string_mv:ACTIVE&fq=code_string:ACLOV &fq=name_usecscontext_en_us_text:ACLOV&fq=productIdentifier_text_mv:ACLOV

So currently the query is adding one fq parameter for every attribute searched for,however I want an OR condition here, something like fq=(gskProductAvailability_string_mv:ACTIVE OR code_string:ACLOV OR name_usecscontext_en_us_text:ACLOV OR productIdentifier_text_mv:ACLOV

How can I enable this through the SearchFilterQueryData or similar? Anyone has faced anything similar?

Regards, Viral