WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] Relevanssi only indexing one document despite all IDs and INSERTS being shown (8 posts)

  1. Adrian Toll
    Member
    Posted 1 year ago #

    I'm having a problem where Relevanssi says "Indexing complete!" when only one document has been indexed.

    I have tried both debugging methods listed here:
    http://www.relevanssi.com/knowledge-base/how-to-debug-indexing-problems/

    The first returns all the IDs, and the second returns a full list of INSERT IGNORE INTO statements.

    To test further I have "Respect exclude_from_search for custom post types" turned off (although it's not indexing any posts that aren't custom posts anyway), and also have "Expand shortcodes in post content" turned off. I have no posts of the default post type at all, as I'm just using pages and custom post types.

    One thing I've noticed is that I'm using a series of characters in the database table names for extra security like xEHbASG, so the tablenames are things like wp_xEHbASG_posts. There's one Relevanssi table which has made all the letters lowercase, so it's called wp_xehbasg_relevanssi rather than wp_xEHbASG_relevanssi. I've manually renamed that table to wp_xEHbASG_relevanssi, but that hasn't made a difference.

    The only other thing that I can think of is I'm using pre_get_posts() to filter search results, and I know that using get_posts() on a search page can cause problems for Relevanssi, but my instinct says that this should only interfere with the results display rather than the indexing. Below is the relevant function. Could this cause problems?

    function xyz_search_filters( $query ) {
    
        // Check if we're on a search results page,
        // that it's the main posts query and that we're not in admin
        if ( is_search() && $query->is_main_query() && !is_admin() ) {
    
            // Make sure we have some useful querystring parameters
            // before setting up filters
            if ( isset($_GET['xyz_resources']) && $_GET['xyz_resources'] == 1 ) {
    
                // Set the post type
                $query->set('post_type', 'resource' );
    
            }
    
        }
    
        // Note that we aren't returning anything.
        // pre_get_posts() is a byref action so we're modifying the query directly.
    
    }
    add_action( 'pre_get_posts', 'xyz_search_filters' );

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, using pre_get_posts should have nothing to do with indexing. What's in the main Relevanssi table (_relevanssi)?

  3. Adrian Toll
    Member
    Posted 1 year ago #

    Hi Mikko, thanks for replying.

    Presuming the "doc" field in that table is the post ID, there are only terms from the one post that's being indexed.

  4. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Yeah, that's the post ID. Strange; so you're getting the right INSERT queries, but only those for one particular post make it to the database. Sounds quite unusual, and I can't really tell what's causing it. Maybe you could try and see if you can get any database errors to print out? Add a

    $wpdb->print_error();

    after the INSERT query is run.

  5. Adrian Toll
    Member
    Posted 1 year ago #

    I've got a bit further with this. I'm not seeing any database errors. However, although there are the correct number of INSERT queries (there are 43 posts, and 43 INSERT queries), they all seem to be using the same post ID. So each INSERT query has a series of brackets like this ...

    (18, 'lorem', 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'post', '', '', 0)

    ... where 18 is the ID of the post that's listed in the wp_relevanssi table. It seems that the code is going through all the posts, but only using / outputting a single post ID. Any idea why that might be happening?

  6. Adrian Toll
    Member
    Posted 1 year ago #

    Hi Mikko

    As you've been kind enough to take the time to help me, I've bought a developer license for Relevanssi (you should see the transaction just before the time of this post). I really like the plugin, and it's great to be using something in active development, so let me know if you'd prefer me to use the Support section on the Relevanssi site to pursue this further, or if you're happy to carry on discussing it here.

    The upgrade to Premium didn't change what's happening, so I'm presuming it must be something in how I've coded the site. Happy to send you a zip file containing the theme if that would help.

    Best wishes

    Adrian

  7. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Please do use the support section – that leads directly to my email. I check these support forums when I have the time for it, and as you can see here, it can take weeks.

    Anyway, I'd check where the post ID is being changed to 18 – does it start like that in relevanssi_index_doc() or does it change at some point? Figure that out, and you're a big step closer to a solution.

    But please do continue this through the premium support, as then you're going to get answers much faster.

  8. Adrian Toll
    Member
    Posted 1 year ago #

    In case anyone else comes across this later and might find the solution helpful, it was my mistake - I'd be trying to use WP_Query in the init hook to set up some custom fields for specific post IDs, but of course the query object hasn't been set up at that point, so it was messing with functions that are called later. Once I'd moved the function to the template_redirect hook, it worked fine.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags