Ignoring special characters in search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Ignoring special characters in search

This topic contains 2 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 7 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10941
    Dimos Tzemanakis
    Dimos Tzemanakis
    Participant

    Hello there,

    Is it possible to ignoring special characters in search query?

    e.g.: Product name: FT-1234, when i search for FT, 1234 or FT-1234 the product displayed but when i search for FT1234 it doesn’t displayed.

    Kind Regards,

    Dimosthenis.

    #10947
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Dimosthenis,

    In this case it’s not possible, because the problem is not in the search phrase, but the way it is stored. From the database point of view (where “FT-1234” is stored) it is told to find something similar to “FT1234”. However for MySQL “FT-1234” and “FT1234” strings are completely different. A possible solution would be to add a delimiter to the search phrase programatically, but then again it’s not possible to tell exactly where it’s position is.

    If the product name was stored as “FT1234” and the search phrase was “FT-1234” then this could be solved very easily, by just removing the dash character before search.

    As a possible solution I would suggest to add the FT1234 string somewhere into the product description, or into excerpt or into a custom field or a tag and configure the plugin to look for that field as well.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #10950
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Addition: Another possible semi-solution is to perhaps use a custom code which tries to recognize numeric strings adjacent to alphabeticals in the search phrase and adding a “-” character between them.

    For that, you can try putting this custom code to the functions.php file in your active theme directory:

    I don’t know how good this will work, but it’s worth a try 🙂

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.