About The Multisearch.php

6 posts by 3 authors in: Forums > CMS Builder
Last Post: May 18, 2017   (RSS)

By Tom - April 3, 2017

Hello,

A question about the multisearch.php

Currently the search field is something like this

'searchFields'    =>  array('ref_no','title_text','studio'),

The question is about the ref_no.

The reference number we stored in the db is something like this

abc123, sss345

The multisearch runs perfect if the user search abc123, abc, abc1

however, if the user search abc-123,

there is no result found.

Please advice is it possible if the user search abc-123,

then the result of abc123 will be shown.

Thanks a lot.

By Damon - April 10, 2017

Hi Tom,

There is no fuzzy logic searching but you can get same results by entering keyword variations to each record.

What you could do is:
1. create a textbox or textfield in that section editor for search variation keywords.
2. add in the possible variations that users may search for:  abc-123, abc123 etc
3. the last step is to add the keywords field name to the 'searchFields' array.

Try this out and let me know if you have any questions.

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Tom - April 12, 2017

Thanks a lot Damon

By Dave - May 18, 2017

Hey Tom, 

As an alternate approach, if dashes aren't needed and you're always searching for ref_no values what about just removing dashes from the keyword the user searches for?  So if they search for ABC-123 or ABC123 or -ABC123- it all searches for ABC123?

$searchOptions['keywords'] = str_replace('-', '', @$_REQUEST['q']); // remove dashes

Hope that helps.

Dave Edis - Senior Developer
interactivetools.com

By Tom - May 18, 2017

Thanks a lot for your great help Dave.