FacetWP schedule a one-time WP-Cron event to re-index all posts

<?php
// Schedules a one-time event to programmatically re-index all posts.
// See this section for how to programmatically schedule one-time re-indexing of all, or a selection of posts:
// https://facetwp.com/help-center/indexing/#trigger-one-time-re-indexing-with-wp-cron
// For periodic, recurring re-indexing, see our Schedule Indexer add-on:
// https://facetwp.com/help-center/add-on-features-and-extras/schedule-indexer/
// To do this for a single post ID, see: https://gist.facetwp.com/gist/facetwp-schedule-a-one-time-wp-cron-event-to-re-index-a-single-post/

// Needs to be availble for WP Cron to run 
function fwp_all_index() {
    FWP()->indexer->index();
}
add_action( 'fwp_all_index', 'fwp_all_index' );

// Place this in a hook or function where you want to initiate indexing, for example after finishing an import. 
wp_schedule_single_event( time(), 'fwp_all_index';