Support » Plugin: Relevanssi - A Better Search » No Search Results With Impreza 7.11 and WordPress 5.7

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Mikko Saari

    (@msaari)

    If you use Query Monitor, do you see anything from Relevanssi? If you set the “Caller” to “Relevanssi”, does that bring up anything on the search results page?

    Does this file exist and if it does, what’s in it?

    us_load_template( 'templates/search' );

    If you try live previewing one of the Twenty* default themes, does the search work there?

    Thread Starter jkndrkn

    (@jkndrkn)

    Hi Mikko, thank you so much for taking the time to respond!

    > If you use Query Monitor, do you see anything from Relevanssi?

    Yes, I see the following when I click Queries > Queries By Caller:

    relevanssi_search: 2 select queries
    relevanssi_populate_array: 5 select queries

    > If you set the “Caller” to “Relevanssi”, does that bring up anything on the search results page?

    Not sure exactly what you mean by this. In “Queries” I can set the “Caller” drop-down on the right to either relevanssi_search or relevanssi_populate_array and examine the exact queries that are being called but this does not affect the search results page. Example: https://imgur.com/pxhjCto

    > Does this file exist and if it does, what’s in it?

    Yes, the file does exist. It is plugins/us-core/templates/search.php.
    These are the contents: https://pastebin.com/gu5JDxDW

    > If you try live previewing one of the Twenty* default themes, does the search work there?

    Using TwentyTwenty in live preview mode I do see expected search results. For one of my terms, “knee”, I see 403 results in live preview VS 431 results in admin search.

    Question: does it look to you like the Impreza theme is the cause of the issue? Would this be something to chat with Impreza support about? Thanks!

    Thread Starter jkndrkn

    (@jkndrkn)

    To add to the above, Impreza support asked me to update to Impreza 7.14.2. I also updated Relevanssi to 4.12.5. I am experiencing the same behavior:

    * Admin search works
    * Live Preview with TwentyTwenty works
    * Site search with Impreza does not work

    Thread Starter jkndrkn

    (@jkndrkn)

    Here is the complete list of queries and stack traces for all WP_Query->get_posts() calls:

    https://docs.google.com/spreadsheets/d/1_mQoiqh8ihLjhrZSdkxaobIvgp16v9MwhUFjJmoTlRE/edit?usp=sharing

    See anything suspicious? I do see that MemberPress and FacetWP are involved in the stack traces. Same thing with Advanced Custom Fields. These are essential plugins that we rely on. Could these be incompatible with Relevanssi?

    By the way, any function prefixed with “us_” is part of Impreza.

    Plugin Author Mikko Saari

    (@msaari)

    What are the queries for relevanssi_search()? There should be two queries for relevanssi_search(), one that begins SELECT COUNT(DISTINCT(relevanssi.doc)) and one that begins SELECT DISTINCT(relevanssi.doc), and it’s the last one I’m interested in. Does that query return the correct number of results, ie. is the “Rows” value right?

    Both MemberPress and FacetWP are compatible with Relevanssi; FacetWP has sometimes been a source of problems and it’s worth checking it out in case that’s the problem here as well, but since the Twenty Twenty search works, it’s possible Impreza is the problem. But it’s worth ruling out a possible problem with FacetWP. Are you using the FacetWP Relevanssi integration plugin? Is FacetWP used in the Relevanssi search or not?

    Thread Starter jkndrkn

    (@jkndrkn)

    Hi Mikko, thank you for your response.

    > What are the queries for relevanssi_search()?

    Below is the second query per your instructions. It returns 414 rows when I run it on the MySQL prompt. The same search on the admin backend returns 430 rows. Perhaps the search parameters between front-end and back-end are different.

    SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 5 + relevanssi.content * 1 + relevanssi.comment * 0.75 + relevanssi.tag * 0.75 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
    FROM wp_26_relevanssi AS relevanssi
    WHERE relevanssi.term = 'knee'
    AND relevanssi.doc NOT IN (18731,18733,343)
    AND ((relevanssi.doc IN (SELECT DISTINCT(posts.ID)
    FROM wp_26_posts AS posts
    WHERE posts.post_type NOT IN ('revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block', 'mp-reminder', 'memberpressrule', 'memberpresscoupon', 'acf-field-group', 'acf-field', 'product_variation', 'shop_order', 'shop_order_refund', 'shop_coupon', 'sfwd-question', 'sfwd-certificates', 'sfwd-transactions', 'us_grid_layout', 'us_header', 'us_content_template', 'us_page_block', 'ld-notification', 'tablepress_table', 'sfwd-essays', 'sfwd-assignment', 'groups', 'wp_stream_alerts')))
    OR (doc = -1))
    ORDER BY tf DESC
    LIMIT 500

    > Are you using the FacetWP Relevanssi integration plugin?

    I am not. The only Relevanssi plugin I am using is the “relevanssi” plugin.

    > Is FacetWP used in the Relevanssi search or not?

    I do not believe so, no. I disabled the FacetWP on my site to test and the issue persists.

    I did notice one odd detail:

    The front-end search fails for some searches but not others. “knee” fails to return any results. “hat” returns the same results in both admin search and front-end search. Do issues with themes cause this kind of problem, typically? Searches that fail for some search terms but not others?

    Plugin Author Mikko Saari

    (@msaari)

    That query looks fine and if it returns over 400 rows, the search should return over 400 results. If the search returns 0 results, that sounds like the theme is discarding the results. But it’s weird if some results do work, generally it’s all or nothing.

    So yeah, I’d say the blame here is on the theme. Without knowing what the theme does, exactly, I can’t really tell what’s wrong here. Relevanssi seems to be performing without problems.

    Thread Starter jkndrkn

    (@jkndrkn)

    Thank you, Mikko. I am going to continue concentrating on the theme. Thanks!

    Thread Starter jkndrkn

    (@jkndrkn)

    I am working with an UpSolutions (Impreza) dev and they pointed me to this file:

    https://pastebin.com/gu5JDxDW

    According to them, on line 54 content is being discarded by this call:

    echo apply_filters( 'the_content', $search_page->post_content );

    The following line does successfully return content but breaks filters that rely on the_content:

    echo do_shortcode($search_page->post_content);

    I commented-out the three places in the relevanssi sources that add hooks to this filter. I also disabled all of the LearnDash plugins because these plugins add a lot of hooks to this filter.

    This did not seem to help.

    Have you seen this particular issue before?

    I also compared all of the relevanssi and WP_Query->get_posts() for search terms that *do* return results and search terms that *do not* return results and it appears that the queries are identical across both successful and unsuccessful searches.

    Have any ideas?

    • This reply was modified 1 month ago by jkndrkn.
    Plugin Author Mikko Saari

    (@msaari)

    So if you remove the apply_filters() from that line, you get all the results returned as expected, just without any features added by the_content?

    In that case the problem is likely some filter added to the_content. You can check what filters are in the_content with this:

    global $wp_filter;
    var_dump($wp_filter['the_content']);

    Add this somewhere near that line, and you’ll see everything that’s added to the_content. You can then start figuring out which filter function is the problem.

    I’ve never seen this issue before, but then again I’ve never run into anyone using Impreza before and whatever Impreza is doing here certainly seems unique.

    Thread Starter jkndrkn

    (@jkndrkn)

    > So if you remove the apply_filters() from that line, you get all the results returned as expected, just without any features added by the_content?

    Correct. If I remove the line containing apply_filters() and replace it with the line containing do_shortcode() I do see all the results returned minus the features added by the_content.

    I am working on a big multisite with lots of priority 10 hooks on the_content and have started going through each hook and disabling it one at a time until I discover the one that is introducing a problem. Could be Impreza or could be something else. Looks like we are on the same page about how to identify this issue.

    Thank you for your continued responsiveness and patience with this issue :] Once I identify the plugin(s) that are breaking the search I will post my findings here in hopes that they will be useful to others.

    Thread Starter jkndrkn

    (@jkndrkn)

    Hi Mikko, I found two cases in our codebase where we had added totally custom hooks to the_content that failed to return content in some cases. It turns out that this issue was not related to Impreza or any other plugin at all. Thank you so much for walking me through this challenging bug!

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