on 2019 Jul 24 2:03 PM
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
Request clarification before answering.
Hello , You can do this using SolrQuery object instead of Hybris out of box classes. Solr provide this functionality so you have to set these condition directly to SolrQuery class. I can provide you way.
Assuming you are using 6.x
Step 1 - Extend DefaultFacetSearchStrategy/AbstractFacetSearchStrategy and override
Step 2 - Override public SearchResult search().
Step 3 - Here object of SolrQuery is available.
Step 4 - solrQuery.addFilterQuery("gskProductAvailability_string_mv:ACTIVE OR code_string:ACLOV OR name_usecscontext_en_us_text:ACLOV OR productIdentifier_text_mv:ACLOV")
This will work. Let me know if help you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are multiple way to this,
Complex is to create you new bean and add this to existing flow like in in DefaultSolrSearchFacade, DefaultSolrSearchService, *Search*Query*Converter, Populator,SearchQuery.
You can populate as SearchFilterQueryData and apply if else in FacetSearchStrategy and remove form SearchQuery what is added by you in SearchFilterQueryData .
Simplest way to do this but use with carefully , set all list in session and get it here.
Hi Viral, you can do this by extending existing SearchFilterPopulator. There you will get SearchQuery object to add filter query and set operator as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Viral,
You can do this the other way round by using the free text search having category filter applied on top
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.