Configure SOLR query to find the Plurals word along with Singular word while forming Query String

Viewed 50

I'm Using a Solr query to sort the search based on the entered search text, currently my query is only working on singular word like filter, car, floor. if i'm searching for the word filter it's only giving the result for filter but i wanted my query to should give the search for filters, cars, floors also. currently it is giving all the results which having word filter, car , floor not there plurals.

below Solr query i'm using for the sort result -- >

https://searchg2.crownpeak.net/NEI-Blogs-Dev/select/?q=custom_s_brand:nei&fl=custom_s_heading,custom_s_article_summary_Image_url,custom_t_content_summary_Image_url_alt,custom_t_content_summary_Desc,custom_s_local_url,custom_s_local_dba,custom_t_heading,termfreq(custom_t_heading,filter*),sum(termfreq(custom_t_heading,filter*)),termfreq(custom_t_content,filter*),sum(termfreq(custom_t_content,filter*))&qf=custom_t_heading&fl=custom_t_content,termfreq(custom_t_content,filter*),sum(termfreq(custom_t_content,filter*))&qf=custom_t_content&sort=sum(termfreq(custom_t_heading,filter*))%20desc,sum(termfreq(custom_t_content,filter*))%20desc&defType=edismax&fq=custom_s_status:Active

1 Answers

Solr does different kind of searches depending on the type of the field that you are searching on.

For string fields the search performs an exact match, hence if the value stored is "car" it will find "car" but not "cars", not even "CAR".

If the field you search on is a text tokenized field then the search will match certain variations depending on how the value was tokenized and what filters were applied to it. For example if you use a built-in text_en field it will perform certain transformations that are typical for values in English and then a search for "cars" or "CAR" will match if the value stored was "car" because the text_en field stores the stem of the word (e.g. "car" for "cars") and this seems to be what you are after.

It looks like the field that you are searching on (custom_s_brand) is a string field, perhaps you want to create additional tokenized fields for the brand so that your searches capture a wider range of matches rather than only identical matches.

Related