• Sadly the search got some huge issue, instead of highlighting the exact match first he will split the whole phrase into single words and seek for it.

    As example
    “Crest of holy fire”
    Would display sites containing “of”

    Workarround is using” “crest of holy fire” “

    So easy to say.. the bug is exact match should displayed first.

    https://wordpress.org/plugins/search-everything/

Viewing 1 replies (of 1 total)
  • I have found the solution for that, Now result match to exact full sentence like – “crest of holy fire”. You just need to add one filter code in your Search Everything plugin.

    1. Open the plugin file – search-everything.php
    2. Search function or keyword – function se_get_search_terms()
    3. Add this line code just before return statement – $search_terms = apply_filters( ‘merge_search_term’, $search_terms );

    function se_get_search_terms() {
    		global $wpdb;
    		$s = isset( $this->query_instance->query_vars['s'] ) ? $this->query_instance->query_vars['s'] : '';
    		$sentence = isset( $this->query_instance->query_vars['sentence'] ) ? $this->query_instance->query_vars['sentence'] : false;
    		$search_terms = array();
    
    		if ( !empty( $s ) ) {
    			// added slashes screw with quote grouping when done early, so done later
    			$s = stripslashes( $s );
    			if ( $sentence ) {
    				$search_terms = array( $s );
    			} else {
    				preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
    				$search_terms = array_filter(array_map( create_function( '$a', 'return trim($a, "\\"\'\\n\\r ");' ), $matches[0] ));
    			}
    		}
         // I have added following filter.
    		$search_terms = apply_filters( 'merge_search_term', $search_terms );
    		return $search_terms;
    	}

    look like this

    4. Now final step, Open your theme functions.php file add the following code

    add_filter( 'merge_search_term', 'callback_merge_search_term', 10, 1 );
    function callback_merge_search_term($search_terms){
    	$merge_search_terms = implode(" ", $search_terms);
    	$one_index_search_term = array($merge_search_terms);
    	return $one_index_search_term;
    }
    • This reply was modified 7 years, 6 months ago by shubham jain.
Viewing 1 replies (of 1 total)
  • The topic ‘Bad Search Results’ is closed to new replies.