• Resolved Dima

    (@aseev)


    Currently the plugin will display results only if a query exactly matches one tag. It is impossible to search combinations of tags, like it is possible for words combinations in post content.

    For example, a post that has tags “car” and “classic” will be displayed if the search query is either “car” or “classic”, but it won’t be if the search is for “classic car”. Logically, it should, since the post contains both of them.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey Dima,

    thanks for the heads up! Until we release an update, we have a fix ready for you:
    1.) In search-everything.php file find the function se_build_search_tag() function. At the moment it looks like this.
    2.) Now replace this with the following code:

    // create the search tag query
        function se_build_search_tag() {
            global $wpdb;
            $vars = $this->query_instance->query_vars;
            $s = $vars['s'];
            $search_terms = $this->se_get_search_terms();
            $exact = isset( $vars['exact'] ) ? $vars['exact'] : '';
            $search = '';
            if ( !empty( $search_terms ) ) {
                // Building search query
                trigger_error("Building search query");
                $n = ( $exact ) ? '' : '%';
                $searchand = '';
                foreach ( $search_terms as $term ) {
                    $term = addslashes_gpc( $term );
                    $search .= "{$searchand}(tter.name LIKE '{$n}{$term}{$n}')";
                    $searchand = ' OR ';
                }
                $sentence_term = esc_sql( $s );
                if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
                    $search = "($search) OR (tter.name LIKE '{$n}{$sentence_term}{$n}')";
                }
                if ( !empty( $search ) )
                    $search = " OR ({$search}) ";
            }
            $this->se_log( "tag where: ".$search );
            trigger_error("Tag search query: " . $search);
            return $search;
        }

    Please let me know how it goes,
    Petra

    Thread Starter Dima

    (@aseev)

    Hello Petra,

    thank you for your quick reply. The new code works. It returns posts which contain at least one march from the query.

    I suggest to match posts that contain all of terms from search query. Otherwise, if I search “red classic car” the result will be all the posts that contain classic and modern cars, classical instruments, and red wine. 🙂

    Thank you for the fix, and let me know if you need help with testing.

    Hey,

    thanks for getting back to me and for the feedback! We know our service is still far from perfect, but I can assure you we are working hard to improve it, so suggestions like yours are more than welcome.

    Once again, thank you for your valuable feedback, take care and have a lovely day!

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

The topic ‘Search query with multiple tags’ is closed to new replies.