problem search words separated by other words, or for another order [AUTOSOLVED]

Started by lopezalejandro, April 01, 2015, 03:18:26 AM

Previous topic - Next topic

lopezalejandro

Hello VM Team,
The other day a user of this forum wrote a private message, in realación this post I wrote years solving a problem:
https://forum.virtuemart.net/index.php?topic=102965

In some version of VM something has changed and the solution is no longer valid.
The problem arises when we look for words that are not together.
You can try it in your tents (do not use words that are in the category or brand, why not verési failure.
An example I have in a shop, in which computers looking for "I5" processor and "SSD", that: "I5 SSD" does not show the same results as "SSD I5"
http://valenciapc.com/ordenadores-portatiles-sobremesa/search/portatiles/notebooks-por?keyword=i5+ssd
The ruling is that words are no longer treated separately, the chain attached sought.
To solve go back to the file:
administrator / components / com_virtuemart / models / product.php in line 276 approx.

before to:
            if (strpos ($searchField, '`') !== FALSE){
               $keywords_plural = preg_replace('/\s+/', '%" AND '.$searchField.' LIKE "%', $keyword);
               $filter_search[] =  $searchField . ' LIKE ' . $keywords_plural;
            } else {
               $keywords_plural = preg_replace('/\s+/', '%" AND `'.$searchField.'` LIKE "%', $keyword);
               $filter_search[] = '`'.$searchField.'` LIKE '.$keywords_plural;
               //$filter_search[] = '`' . $searchField . '` LIKE ' . $keyword;
            }

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

Save, and close.
Thanks and sorry form my english, it's 3 AM....i'm going to get some sleep
Alejandro López
Grupo Odín Soluciones Informáticas
http://grupoodin.es

Milbo

I would like to have a solution for , I5 SSD, "I5 SSD", and I5 + SSD.
I5 SSD searches for all products which have I5 AND SSD
"I5 SSD" searches for exactly I5 SSD
and I5 + SSD searches for  I5 OR SSD

or something like that.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

lopezalejandro

Hi Max
Sorry but the search does not work properly.
It is important for traders that if customers are looking for "RED BOX", then the results will show products with name: "RED AND BLUE BOX".

The solution is to add the line:
  $keyword = preg_replace('/%/', ' ', $keyword);
before the code you added in 2012 which solved the problem.

I ask you to add it in the next version of VM
Alejandro López
Grupo Odín Soluciones Informáticas
http://grupoodin.es

balai

Alejandro I don't think that this solution is always good.
Think for example a text containing the phrase "RED BOX WITH BLUE STRIPES" and the user is searching using "BLUE BOX". Then this product will be returned although it is not correct.

From my point of view the search should tokenize the phrase to find the important terms and also find words with special meaning "AND, OR, NOT" in order to generate the proper query

lopezalejandro

The humans not know the posibility of search with AND, OR, NOT.
Your example is little problem.
The user looks like google searches.

If the human search in the shop "blue red" and the name of product is "RED BLUE", VirtueMart dont display search results.
Relly you prefer it??


Alejandro López
Grupo Odín Soluciones Informáticas
http://grupoodin.es

Milbo

Quote from: lopezalejandro on April 01, 2015, 12:27:48 PM
The humans not know the posibility of search with AND, OR, NOT.
The user looks like google searches.

Yepp, the real question is to find a common search language, so that most people use it correctly.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

kmogongora

I was the user that posted this problem, and the solution works perfect!!!


Thanks for your help!!

usermee

Quote from: lopezalejandro on April 01, 2015, 12:27:48 PM
The humans not know the posibility of search with AND, OR, NOT.
Your example is little problem.
The user looks like google searches.

If the human search in the shop "blue red" and the name of product is "RED BLUE", VirtueMart dont display search results.
Relly you prefer it??


Great fix, and I agree with you completely, this should be included in future versions of virtuemart to fix the search function. Thanks lopezalejandro!