In Quick Search you can choose:
Auto
Exact Match
All Keywords
Any KeywordsBut in Advanced Search - Any Keywords is not working.
I’ve enabled Advanced Search for field (varchar 255) in table with Operator LIKE. When i search values in that field (contains) - it can’t search with more then one word.
E.g.> Search Product Type: jeans > displays results from the table
Search Product Type: blue jeans > doesn’t display results.This type of Search works within SQL as LIKE %…%
Possible to add this to advanced search operator?
I just had a similar issue, check this thread, maybe the solution works for you too:
The field is using a lookup table (productypeID, display ProductTypeName).
Unfortunately enabling Auto-Suggest all display fields from Tools → Advanced Settings, and re-generate ALL the script files doesn’t work.
In Quick Search - any keywords is working.
In Advanced Search it still searches only one word.
in Advanced Search field ProductType performs search only with one keyword.
It can’t search with more then one word.
Example:
Search Product Type: jeans > displays results from the table.
Search Product Type: blue jeans > doesn’t display results.Advanced Search for that ProductType field would need functionality as QuickSearch: Any keywords.How to use Recordset_Searching server event to modify (split the keywords and rebuild the filter) the part of the filter for the field?
What would be the code example for this type of Recordset_Searching server event?
You may, for example,
- Get the searched keywords from the field object’s SearchValue property from Recordset_SearchValidated server event.
- Split the keywords and build the filter you want.
- Use Recordset_Searching server event to replace the filter for that field (see example in help file) with the one you built.
Could something like this work in Recordset_Searching?
function Recordset_Searching(&$filter) {
$keywords = $db->escape_string($_GET['keywords']);
$query = $db->query("SELECT title FROM products WHERE '%{$keywords}%' LIKE '%{$keywords}%' ");
}
- There is no $db
- There is no $_GET[‘keywords’]
- You did you split the keywords and built a filter
- The WHERE clause of your SQL is incorrect, and you did not use your $query at all.
You may use AddFilter() global function in that server event, which is similar to Recordset_Selecting server event.
Please always refer to the documentation for more info and example.
How to assign variable to get entered words in advanced search input box?Something like this?function Recordset_Searching(&$filter) {
$ProductTypeName = AdvancedSearch->SearchValue.;
$filter = (ProductTypeName LIKE ‘%“.$ProductTypeName.”%’), $filter);
}
Assume the field name is ProductTypeName, then try:$ProductTypeName = $this->ProductTypeName->AdvancedSearch->SearchValue;
Unfortunately this generates an error (An internal error has occurred while processing your request.) :function Recordset_Searching(&$filter) {
$ProductTypeName = $this->ProductTypeName->AdvancedSearch->SearchValue;
$filter = (ProductTypeName LIKE ‘%“.$ProductTypeName.”%’), $filter);
}Any info what to fix here to get it working?
Change this code:
$filter = (ProductTypeName LIKE ‘%“.$ProductTypeName.”%’), $filter);to:
AddFilter($filter, “ProductTypeName LIKE '%”.$ProductTypeName.“%'”);
Thank you for the update! This works but still getting no results for two words search.
Example:
Advanced Search: jeans —> produces search results.
Advanced Search: jeans black ----> no records were found. How to correct this to work with at least two words?