• We have noticed that our events (Time.ly All-In-One Event Calendar) are not being searched.

    I did a search for a uniquely named event and get no results found. “MeshugaNutcracker” is the term I searched for knowing it is the only in Events. It should come up with this post: https://www.jmoreliving.com/event/the-meshuganutcracker/?instance_id=2740

    On our dev site, the search is working once I reindexed. The dev site has very few posts and events. The live site has thousands. I noticed that quite a few are excluded and the log sticks on on “Indexed 60 posts …” Below is the log. Any thoughts on why it is not searching the events would be appreciated. In the settings I have “ai1ec_event” checked under Post types to make sure it is part of the search.

    Wiping out the index… Done.
    Counting posts… 2700 posts found.
    Indexed 10 posts (total 10), processed 10 / 2700.
    Indexed 25 posts (total 35), processed 35 / 2700.
    Indexed 30 posts (total 65), processed 65 / 2700.
    Indexed 35 posts (total 100), processed 100 / 2700.
    Indexed 40 posts (total 140), processed 140 / 2700.
    Indexed 45 posts (total 185), processed 185 / 2700.
    Indexed 50 posts (total 235), processed 235 / 2700.
    Indexed 55 posts (total 290), processed 290 / 2700.
    Indexed 60 posts (total 350), processed 350 / 2700.
    Indexed 60 posts (total 410), processed 410 / 2700.
    Indexed 60 posts (total 470), processed 470 / 2700.
    Indexed 60 posts (total 530), processed 530 / 2700.
    Indexed 60 posts (total 590), processed 590 / 2700.
    Indexed 60 posts (total 650), processed 650 / 2700.
    Indexed 60 posts (total 710), processed 710 / 2700.
    Indexed 60 posts (total 770), processed 770 / 2700.
    Indexed 60 posts (total 830), processed 830 / 2700.
    Indexed 60 posts (total 890), processed 890 / 2700.
    Indexed 60 posts (total 950), processed 950 / 2700.
    Indexed 60 posts (total 1010), processed 1010 / 2700.
    Indexed 60 posts (total 1070), processed 1070 / 2700.
    Indexed 60 posts (total 1130), processed 1130 / 2700.
    Indexed 60 posts (total 1190), processed 1190 / 2700.
    Indexed 60 posts (total 1250), processed 1250 / 2700.
    Indexed 60 posts (total 1310), processed 1310 / 2700.
    Indexed 60 posts (total 1370), processed 1370 / 2700.
    Indexed 0 posts (total 1370), processed 2700 / 2700.
    Indexing complete. 1330 posts excluded.

    The page I need help with: [log in to see the link]

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

    (@msaari)

    First: do you have Relevanssi 4.0.2? If not, update now, try again and let me know if the problem persists.

    If the problem remains after the update, does clicking “Index unindexed posts” index those remaining posts, or do they stay excluded?

    The indexing doesn’t get stuck –?it just keeps repeating “Indexed 60 posts” because that’s how many it can index on one go (Relevanssi indexes as many as it can in up to 10 seconds). The total number of indexed posts is 1370, which is better than 60, but certainly not everything.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    I do have 4.02 installed. I ran Index Unindexed Posts and it indexed the remaining posts. Cleared cache. Ran a search. Still not searching Events.

    Plugin Author Mikko Saari

    (@msaari)

    Your theme is restricting the post types. If you force the post type to a1ec_event, the events show up: https://www.jmoreliving.com/?s=nutcracker&post_types=ai1ec_event

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    How do I force it to unrestrict the post types? I do have a message in to the theme maker. Weird part is that somehow it is working on the same theme on the dev version of this site. I thought it was maybe because the dev site has maybe 100 posts and the live has 2700.

    Plugin Author Mikko Saari

    (@msaari)

    I don’t know how the theme is restricting the post type, but this should help:

    add_filter('relevanssi_modify_wp_query', 'rlv_force_post_types');
    function rlv_force_post_types($query) {
        $query->query_vars['post_types'] = "post,ai1ec_event";
        return $query;
    }

    Add to the list the post types you want included and add this to your theme functions.php.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    That works. It does show expired events in the results. I guess there is no way around that since removing expired would also hide expired articles on the website. I’ve also been asked to remove the byline for just Event results. I’ll see if I can figure that out too.Thanks for the help.

    Plugin Author Mikko Saari

    (@msaari)

    To remove the expired events, a good solution is to add a filter function on relevanssi_hits_filter hook that goes through the posts and removes the expired events.

    add_filter('relevanssi_hits_filter', 'rlv_remove_expired');
    function rlv_remove_expired($hits) {
        $non_expired = array();
        $now = time("Y-m-d");
        foreach ($hits[0] as $hit) {
            $event_date = get_post_meta($hit->ID, 'event_date', true);
            if (!empty($event_date) && $event_date < $now) continue;
            $non_expired = $hit;
        }
        $hits[0] = $non_expired;
        return $hits;
    }

    Something like this.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    I appreciate the additional code, however, it seems to break the search functionality entirely. I did a search for “Motor House” using the previous unfiltered code which showed the expired Event on the first page of results at the bottom. It showed pages of results Events, Posts, and Pages.

    I switched that code out for the new filtered version. When I did the same search I get “No Results”

    I have removed both pieces of code for the moment.

    Plugin Author Mikko Saari

    (@msaari)

    That wasn’t functional code, just an example of how it can be done. For starters, I have no idea what’s the name of the event date custom field, “event_date” was just a placeholder. So no wonder it doesn’t work. That’s, however, the principle how expired events are removed.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    I apologize. I misunderstood. Let me see if I can figure it out using this code as base for experimentation.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    Mikko,

    I have been playing around with the code for hours now. One thing I discovered is a flaw in your code. If I put just this in:

    add_filter('relevanssi_modify_wp_query', 'rlv_force_post_types');
    function rlv_force_post_types($query) {
        $query->query_vars['post_types'] = "post,ai1ec_event";
        return $query;
    }
    add_filter('relevanssi_hits_filter', 'rlv_remove_expired');
    function rlv_remove_expired($hits) {
        $non_expired = array();
        foreach ($hits[0] as $hit) {
    	   $non_expired = $hit;
       }
       $hits[0] = $non_expired;
        return $hits;
    }

    It generates no results. If I change the code to this”array_push”:

    add_filter('relevanssi_modify_wp_query', 'rlv_force_post_types');
    function rlv_force_post_types($query) {
        $query->query_vars['post_types'] = "post,ai1ec_event";
        return $query;
    }
    add_filter('relevanssi_hits_filter', 'rlv_remove_expired');
    function rlv_remove_expired($hits) {
        $non_expired = array();
        foreach ($hits[0] as $hit) {
    	   array_push($non_expired, $hits);
       }
       $hits[0] = $non_expired;
        return $hits;
    }

    It give me results, but no content. Meaning it shows “by:” and no meta data. It looks like this. It shows 5 formatted but blank results.:

    <article id="post-" class="et_pb_post">
    <h2 class="entry-title"><a href=""></a></h2>
    <p class="post-meta"> by <span class="author vcard"></span> | <span class="published"></span></p>
    <p class="ArchiveReadMore"><a href="" class="more-link">read more</a></p>
    </article>

    So is there some way to get the actual content to show in that scenario? The filtering of expired I think I figured out, but I need the results to show.

    Plugin Author Mikko Saari

    (@msaari)

    Indeed, it was supposed to be $non_expired[] = $hit;

    So it should be array_push($non_expired, $hit); in your case. That should show you content and include every post.

    Then just add the check for expiry date and skip the posts that have expired.

    Thread Starter lutzcreativegroup

    (@lutzcreativegroup)

    Using $non_expired[] = $hit; now and the results are SHOWING. THANK YOU! Very close to having this working. Just need to grab the end date from the events plugin and I should be golden. I really appreciate your help with this.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Not Searching Events’ is closed to new replies.