This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Search results with or without space

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search results with or without space

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #48861
    TwinsenseTwinsense
    Participant

    Best,

    I get different search results when entering the becoming with space and without space, for example ‘NEN 3140′ and NEN3140’. See screenshots attached. I am using your index table. Can you help me what I have set wrong here? I would like the same search results regardless of the use of spaces or capital letters.

    Thanks in advance,
    Tom Verkooijen

    #48892
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    I’m afraid this may not be possible. I could go into pages on pages to explain why, but to put it simply it’s basically a database query limitation.

    I see a possible solution though via a small custom code snippet, but it’s no magic. This snippet will separate/put spaces silently before sending the query between numbers and letters, so for most cases should yield the same output.

    add_filter(
    	'asp_search_phrase_before_cleaning',
    	function ( $phrase ) {
    		preg_match_all('/([0-9]+|[a-zA-Z]+)/', $phrase, $matches);
    		return implode(' ', $matches[1]);
    	}
    );

    Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.