• Resolved Simon

    (@conpark)


    Hi,

    is it possible to re-index some autocomplete indices with a cron job?

    Our algolia index is somtimes not up to date.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I have to believe there’s a way, but I’m not finding an example just yet. Mostly I was trying to dig in to how the plugin handles the re-index button in the admin and what code gets executed in that process, so that it could be repeated in your cron job.

    Thread Starter Simon

    (@conpark)

    Hi Michael,

    thank you! Let me know if you find something ??
    I will check for a solution as well.

    Thread Starter Simon

    (@conpark)

    If there is anyone with an idea for the problem… I would be very happy ??

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Discussed some things internally and came up with some possible ideas.

    If you’re willing/able to do a real cron job, and not WordPress’ “cron” job, you could use something like WP-CLI. We ship with this command available:

    NAME
    
      wp algolia reindex
    
    DESCRIPTION
    
      Push all records to Algolia for a given index.
    
    SYNOPSIS
    
      wp algolia reindex [<indexName>] [--clear] [--all]
    
    ALIAS
    
      re-index
    
    OPTIONS
    
      [<indexName>]
        The id of the index without the prefix.
    
      [--clear]
        Clear all existing records prior to pushing the records.
    
      [--all]
        Re-indexes all the enabled indices.
    

    Regarding the re-index buttons in the admin, they’re apparently handled via some “javascript shenanigans” and wouldn’t necessarily be readily available to PHP/WP Cron.

    “Otherwise, we do not yet have any sort of built-in WP-Cron, because re-indexing in WP-Cron would be prone to timeouts and/or out of memory errors, if you have a lot of posts”

    Thread Starter Simon

    (@conpark)

    Hi Michael,

    thank you for your reply!
    Unfortunately we’ve no WP-CLI available on the server ??

    Isn’t there any other way to trigger the button.
    It doesn’t have to be with the WP-Cron.
    If it helps we could use a service like easycron.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Despite it not being available now, it should be pretty easy to download a copy of WP-CLI as long as you have SSH access into the server.

    https://wp-cli.org/#installing

    Beyond that, I’d need to re-try to reverse engineer the code to see if there’s any way to programmatically trigger those parts.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Re-index Autocomplete index with cron job?’ is closed to new replies.