on 2021 Mar 09 10:04 AM
Hi all,
We are trying to leverage SOLR date filter [NOW TO *] to not pick certain records which are expired
Problem Statement :- SOLR is not considering the end date of discount rows . This is causing invalid discount rows returned from SOLR .
We do have attributes in SOLR and if i am able to filter them directly if i add *_customerDiscount_string:[NOW TO *] in SOLR console. But when i pass this from populator space is getting converted
[NOW TO *] -> [NOW+TO+*]
[NOW\\ TO\\ *] -> [NOW \ TO \ *]
In general , i am struggling to find a way to pass the space back to SOLR as it gets converted in Java itself which is not any custom code
see one sample SOLR response for your reference
Sample SOLR query generated below for your reference
Any help would be highly appreciated
Request clarification before answering.
You may achieve what you want by extending SearchFiltersPopulator or creating a new Populator to commerceSearchQueryPageableConverter.
Something similar to the following should work in the populator
target.getSearchQuery().addQuery("customerDiscount", SearchQuery.Operator.AND, SearchQuery.QueryOperator.GREATER_THAN, "NOW");I tried this on my local setup with version 1905.24, and it is translated like the following
priceValue_try_double:[100.00000000000001 TO Infinity])If it does not work, you can give it a try to the following, but I suggest to the previous one.
target.getSearchQuery().addFilterRawQuery("customerDiscount_string:["NOW TO *]");Since solr implementation is heavily dependent on the SAP Commerce version and configuration (whether legacy mode is active or not, availability of SearchQueryTemplate definition(s) affect the conversion of SolrQuery) I suggest you to debug populators during SolrQuery conversion, especially to DefaultFacetSearchStrategy (or LegacyFacetSearchStrategy if you enable LegacyMode). Conversion happens in it's method named search(SearchQuery searchQuery, Map<String, String> searchHints). To be more specific, exact conversion is in the following line
SolrQuery solrQuery = (SolrQuery)this.facetSearchQueryConverter.convert(searchQueryConverterData);So you need to debug facetSearchQueryConverter and its populators also.
There is a lot of debugging to understand conversion and what field you need to modify or add 🙂
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.