News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Searching error based on reading left to right

Started by kittmaster, October 15, 2015, 16:38:56 PM

Previous topic - Next topic

kittmaster

I have an issue with search results. I'm using my products as song building lists.

When I search for:

Rush Tom Sawyer returns 2 results found.
Tom Sawyer Rush returns no results found.

Is this a problem in the search routine?

How can I fix this?

Chris

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

GJC Web Design

just tested on J3.4.4 / VM3.0.10 and correct   .. reversed it isn't found because the query is 

  WHERE product_name LIKE "%classic%hat%" ---

"%hat%classic" would find nothing

I guess would need to be something like

WHERE `product_name` LIKE '%hat%'
OR `product_name` LIKE '%classic%

or  WHERE `product_name` REGEXP 'hat|classic'

but then every product with hat or classic would be returned -- as you can see your particular request wouldn't perhaps suit a lot of users

there is the possibility for a  search plugin to be called in the products.php model but have never tried to code one
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

kittmaster

Well isn't that really the point of search......to return any and all matches?

For my example, its not like its a literal opposite, the terms are the terms and it should be returning anything within that word set regardless of its order.

I've never coded one either, when you looked, was it in a template so I could reform and override the default behavior?

Songs, products, when you type into Amazons engine, the order in which its typed is irrelevant and returns all values of the search string, shouldn't that be done the same here?

I could use some guidance if possible to make my more usable for my customers.

Any insight would be great.

Thanks again,
Chris

GJC Web Design

 .. either a core hack in products.php model or build a search plugin to achieve the above sort of query....

the search currently is what it is.....
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

kittmaster

#5
True and thanks for trying to assist.

I did go back and do some further looking to see if I could gain any insight, and it appears that someone has found a solution that works good for my needs. I would also think that it would help others and should be added to the core with a user switch to turn it on and off.

The fix I found and tested is here:

http://forum.virtuemart.net/index.php?topic=129146.0

administrator/components/com_virtuemart/models/product.php

by adding:


$keyword = preg_replace('/%/', ' ', $keyword);


To look like:


else if ($searchField == 'product_name' or $searchField == 'product_s_desc' or $searchField == 'product_desc' or $searchField == 'slug' ){
$langFields[] = $searchField;
//if (strpos ($searchField, '`') !== FALSE){
//$searchField = '`l`.'.$searchField;
$keyword = preg_replace('/%/', ' ', $keyword); // <<<<<<< Added line that fixes search order
$keywords_plural = preg_replace('/\s+/', '%" AND '.$searchField.' LIKE "%', $keyword);
if($app->isSite() and VmConfig::$defaultLang!=VmConfig::$vmlang and !VmConfig::get('prodOnlyWLang',false)){
$filter_search[] =  '`ld`.'.$searchField . ' LIKE ' . $keywords_plural;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){

$filter_search[] =  '`ljd`.'.$searchField . ' LIKE ' . $keywords_plural;
}
}
$searchField = '`l`.'.$searchField;
//}
}


It seems to work brilliantly on my site using 3.0.10.

I HATE doing it this way, and I know I'll have to keep fixing it every time a new update comes out, but my customers need to be able to find what they need when they search.....hopefully someone can convince the devs to add this to the core....exact phrase searching is INEFFECTIVE and leads to user frustration.....people want to see all the options and choose as they need......IMO.

Thanks for your help and I hope this may help others in the future.

Chris

Milbo

You can do that, with your own searchplugin, I may take a look later to integrate your idea. Mainly not a big deal, but as GJC already point out, for a lot users it would not be a good solution
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

kittmaster

Understood, why not just make it a checkbox in the admin area? Could say something like "search exact" or "search all" depending on setting.

I've never written a plugin so therefore, trying to grow my own is just not feasible....I just need it to work.

:)

Thanks,
Chris