Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter swinggraphics

    (@swinggraphics)

    Is this the best/only way?

    add_filter( 'wpfts_index_post', function( $index, $post ) { 
        if ( 'my_cpt' == $post->post_type ) {
            $index[ 'post_title' ] = '';
            $index[ 'post_content' ] = '';
        } 
        return $index; 
    }, 3, 2 );

    Would I also need to add $index[ 'clust_name' ] line for each custom cluster?

    Plugin Author Epsiloncool

    (@epsiloncool)

    Hi @swinggraphics

    Yes, if you really want to remove some post types from search, it’s the good code.
    However this makes impossible to search those posts too.

    Alternatively you can use pre_get_posts hook (since we haven’t UI for this yet)

    
    add_action('pre_get_posts', function ($wpq){
        if ($wpq->is_search && $wpq->is_main_query()) {
             $wpq->set('post_type', array(...list of posts you want to search by...));
             $wpq->set('post_status', array('publish'));  // You can justify the list of statuses too
        }
    });
    

    No, you don’t need to add ‘clust_name’, why?

    Thread Starter swinggraphics

    (@swinggraphics)

    Thanks. It’s good to note that pre_get_posts can filter results, but I am specifically looking to reduce the size and time of indexing. My site with 300 pages took 15 minutes to index. As I tweak and customize, I’ll have to rebuild. I don’t want to keep waiting that long. Same site with Relevanssi took a few seconds.

    Plugin Author Epsiloncool

    (@epsiloncool)

    Yes, @swinggraphics, the indexing takes more time and space, mainly because WPFTS uses the TF-IDF principle that is different from the one used in Relevanssi. However, 300 pages for 15 minutes sounds a bit long for me. Anyway, it’s a one-time task and you don’t need to rebuild the index too often (hopefully never) after the configuration of the wpfts_index_post hook.

    We are still working on optimizations, anyway. And in the nearest future, it will be possible to reindex only a touching set of posts (for example, only one post_type post, etc).

    Thanks for your notice, it’s important to make more quality product.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude post types’ is closed to new replies.