WordPress Relevanssi Plugin Missing Search Results Issue

I am having a problem with a WordPress website that uses the Relevanssi search plugin. It seems that some posts are not appearing in the search results even though they should. For instance, when I search for the term “education”, I expect to see a post titled “Melbourne High School - Education & Development Project”, but it doesn’t come up. However, searching for just “melbourne” does show that post.

Here is the template code I’m using for displaying search results:

<?php if (have_posts()): ?>
    <div class="search-results">
    <?php while (have_posts()) : the_post(); ?>
        <?php
            $content_type = get_post_type();
            $breadcrumb = '';
            $view_more = '';
            $summary = '';

            if( $content_type == 'portfolio' ) {
                $terms = get_the_terms(get_the_ID(), 'category');
                $main_cat = get_post_meta(get_the_ID(),'_yoast_wpseo_primary_category',true);
                if($main_cat){
                    $terms = null;
                    $primary_term = get_term($main_cat, 'category');
                    $terms[] = $primary_term;
                }
                $breadcrumb = '<a href="/portfolio/">' . $work . '</a>';

                if($terms) {
                    $breadcrumb = $breadcrumb . ' / <a href="/portfolio/#' . $terms[0]->slug . '">' . $terms[0]->name . '</a>';
                }
                $breadcrumb = $breadcrumb . ' / <a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
                $view_more = get_the_permalink();
                $summary = get_the_excerpt();
            }

            if( $content_type == 'articles' ) {
                $terms = get_the_terms(get_the_ID(), 'article_category');
                $breadcrumb = '<a href="/articles/">' . $blog . '</a>';
                if($terms) {
                    $breadcrumb = $breadcrumb . ' / <a href="/articles/#' . $terms[0]->slug . '">' . $terms[0]->name . '</a>';
                }
                $breadcrumb = $breadcrumb . ' / <a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
                $view_more = get_the_permalink();
                $summary = get_the_excerpt();
            }

            if( $content_type == 'recognition' ) {
                $breadcrumb = '';
                $view_more = '/about/recognition/';
                $summary = get_the_excerpt();
            }

            if( $content_type == 'staff' ) {
                $breadcrumb = '';
                $view_more = '/about/team/';
                $summary = get_the_title();
            }

            if( $content_type == 'office' ) {
                $breadcrumb = '';
                $view_more = '/contact-us/';
                $summary = get_field('street_address');
            }

            if( $content_type == 'page' ) {
                $breadcrumb = '';
                $view_more = get_the_permalink();
            }
        ?>
        <div class="result-item" id="<?php echo get_the_ID(); ?>">
            <div class="text-content">
                <h3><?php the_title(); ?></h3>
                <div class="breadcrumb">
                    <?php echo $breadcrumb; ?>
                </div>
                <div class="description"><?php echo $summary; ?></div>

                <a href="<?php echo $view_more; ?>">View Details</a>
            </div>

            <?php if(wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'medium'  )) : ?>
            <div class="thumbnail" style="background-image: url('<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'medium'  ); echo $thumb[0]; ?>')"></div>
            <?php endif; ?>
        </div>
    <?php endwhile; ?>
    </div>
<?php else: ?>
    <div class="no-results">
        No matches found
    </div>
<?php endif; ?>

I also added this function to my functions.php file, but it has not resolved the issue:

function custom_search_filter( $query ) {
    if ( $query->is_search ) {
        $query->set( 'post_type', array( 'portfolio', 'articles', 'recognition', 'staff', 'office', 'page') );
        $query->set( 'post_status', array( 'publish') );
    }
    return $query;
}
add_filter( 'pre_get_posts', 'custom_search_filter' );

When I disable the Relevanssi plugin, the search functions correctly and shows all matching posts. However, I want to use Relevanssi because it improves the relevance of the search results. Has anyone else experienced this issue? Any suggestions on what might be the reason certain posts are not appearing in the Relevanssi search results?

Had the same issue last year - Relevanssi indexed some posts but completely skipped others with identical content types. Turned out to be a conflict between my custom post type settings and Relevanssi’s defaults. Go to your Relevanssi settings under “Indexing” and double-check that all your custom post types (portfolio, articles, recognition, etc.) are actually selected for indexing. Your pre_get_posts filter might specify them, but Relevanssi won’t index them unless they’re enabled there too. Also check if the missing posts have weird custom fields or metadata - sometimes posts with certain custom field values get skipped during indexing. Pull up one of the missing posts and compare its content structure to posts that actually show up in search results.

Also check your Relevanssi excerpt settings - sometimes posts get indexed but won’t show up because of how the plugin generates excerpts. I’ve seen this where certain posts index fine but get skipped when displaying search results. Try turning off excerpt highlighting or switching the excerpt type in Relevanssi settings to see if that fixes your missing posts.

Classic Relevanssi indexing issue - I’ve hit this tons of times. Since “melbourne” pulls up the post but “education” doesn’t, either that word didn’t get indexed properly or there’s a config problem with how Relevanssi handles it. Go to your WordPress admin, hit Relevanssi settings, and click “Build the index” to rebuild everything from scratch. This usually fixes missing content problems. Also check if you’ve got stopwords set up that might be blocking “education” - probably not since it’s not a typical stopword, but worth checking. Make sure the post status and type match what Relevanssi’s actually indexing. Your custom search filter might be clashing with Relevanssi’s post type handling, so try killing that function temporarily and see if it fixes things.