cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to remove Special Charecters while searching in Solr

former_member657112
Discoverer
0 Kudos
898

Hi Experts

I have a query

if the Customer Part # is 48-32-4024, then the user will be search both ways "48-32-4024" or as "48324024"

then the user should get the product .

Accepted Solutions (0)

Answers (2)

Answers (2)

a_e_dubey
Active Participant
0 Kudos

Hi mahendher

There can be two way of parsing value of part#

  • Try to get list of special character in part# and remove at time of indexing and searching.
  • Use type text field in solr and use ftsQuery,wildcardquery,fuzzyquery feature.
Former Member
0 Kudos

Hi,

In previous hybris version before 5.7 we had DefaultFacetSearchService using SolrQueryConverter to hold reference of all defined query post-processors hooks.

Search Query Post-Processors and Search Result Post-Processors- These were query post-processors that operate on the Solr query object and the search result object returned from the Solr index search respectively. But Post-Porcessors got deprecated and only works when the legacy mode is enabled in the search configuration.

Post version 5.7 Hybris provides a list of the listener types and you can use FacetSearchListener interface as you want to intercept execution of search queries.

You can write a class say DefaultFacetSearchListener which must implement FacetSearchListener interface and override its methods and can get what you need from FacetSearchContext parameter.

public class DefaultFacetSearchListener implements FacetSearchListener

{

@Override

public void afterSearch(final FacetSearchContext facetSearchContext) throws FacetSearchException

{

final SearchResult searchResult = facetSearchContext.getSearchResult();

final QueryResponse solrObject = searchResult.getSolrObject();

final NamedList<Object> response = solrObject.getResponse();

final NamedList responseList = (NamedList) response.get("responseHeader");

final NamedList paramsList = (NamedList) responseList.get("params");

....

....

....

}

}

Regards,

Prashant