Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search matching only ends of strings › Reply To: Search matching only ends of strings
You are welcome 🙂
Well it’s not possible with the index table in sense of the performance. There is a MySQL behavior that the index table uses to gain performance. Basically the database can create so called “indexes” that are accessible at a very low cost in a very high speed. There are limitations however to use these indexes – especially when searching. The limitation is that you can only search from the beginning of the words. (the ending is solved by storing the reverse of the string in the same table). If you however decide to look for matches within the words then the database will not use these indexed values for fast access, since the foundation of the index is that the matching has to begin with the first character.
The reason why is it like this is roots in rather complicated math and binary trees and such.
Basically the index table engine provides very precise matches at high speed but at the cost of not be able to search in the middle. The regular engine provides wider set of matches, but the relevance is much worse.
I can suggest a modification to be able to look in the “middle” of the indexed values, but I strongly recommend testing it before live usage. I have never tried that, and it might cause large performance peaks in the mysql process on your server.
Open up the wp-content/plugins/ajax-search-pro/includes/search/search_indextable.class.php file and scroll to line 564, which should be this:
$like_query = "asp_index.term LIKE '".$word."%'";
change that line to:
$like_query = "asp_index.term LIKE '%".$word."%'";
and that’s it. The index table engine now should be returning results even if it matches words in the middle.Best,
If you like my products, don't forget to rate them on codecanyon :)