Jump to content

Strange searching results


Recommended Posts

Hello,

I noticed that there is a problem with finding. I have a new installation, without added modules if you write in the search box "ipod", the result is: "5 results have been found."

But if you write "pod", the result is: "No results were found for your search "pod""
Is it just me have this problem
and how to solve it?

 

p.s. In the admin panel, searching box working fine.

 

Thanks

Edited by chipset (see edit history)
Link to comment
Share on other sites

Hi!

This is because pod is not indexed as a search word. You can use aliases for that (preferences->search).

 

If you want, however, you can slightly edit the search class to allow searching inside keywords. THis will, however, slow down the search process a bit (depending on your server's performance)

Link to comment
Share on other sites

Thanks for the reply Nemo1.

Options with aliases may be working at the store with 10 items, but if you have 1000 +?
In preferentses wrote that I have 7/7 indexed. For each case, Re-build the entire index, but still do not find the word "pod".
I tried different weight, but the problem is not in the speed or arrangement, just finds nothing
.

How search in the admin panel finds all? Can I use it in front?

Link to comment
Share on other sites

If you want to go for the modification, reach line 185 (about), of classes/Search.php, you'll see this

				$intersect_array[] = 'SELECT si.id_product
					FROM '._DB_PREFIX_.'search_word sw
					LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
					WHERE sw.id_lang = '.(int)$id_lang.'
						AND sw.id_shop = '.$context->shop->id.'
						AND sw.word LIKE
					'.($word[0] == '-'
						? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
						: '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
					);

Change it to

				$intersect_array[] = 'SELECT si.id_product
					FROM '._DB_PREFIX_.'search_word sw
					LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
					WHERE sw.id_lang = '.(int)$id_lang.'
						AND sw.id_shop = '.$context->shop->id.'
						AND sw.word LIKE
					'.($word[0] == '-'
						? ' \'%'.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
						: '\'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
					);

As you can see I added a % sign at the beginning as well, this will have the search look for any occurrence of the string, instead of only the ones which begin with the given one

  • Like 2
Link to comment
Share on other sites

  • 2 months later...
×
×
  • Create New...