index post meta on update

  • wpsolr
    Keymaster
    3 years, 11 months ago #19838

    Yes, WPSOLR is hooked on wp_post_update to detect real-time changes.

    You should use it to trigger the reindexing. And it certainly costs much less than update_post_meta that you already use.

    Or, you can use our cron extension to schedule a full/incremental reindexing every night.

    dnikola
    Participant
    3 years, 11 months ago #19850

    I think I made mistake with a name, and than you repeated it, so function wp_post_update is actually wp_update_post ?

    Are you sure that you hooked on this function? I am not sure how I can update post meta with that function according wp codex it is not possible?
    every where is suggested to use update_post_meta function :/

    wpsolr
    Keymaster
    3 years, 11 months ago #19851

    WPSOLR is hooked to WP actions for triggering real-time indexing: save_post, add_attachment, edit_attachment, delete_attachment, create_term, edit_term, pre_delete_term, comment_post, wp_set_comment_status.

    dnikola
    Participant
    3 years, 11 months ago #19852

    aha, I am using save_post_{$post_type}

    so i need to switch to save post and to check for custom post type inside function.

    Ok, but this is maybe idea if custom post are indexing to hook on this also…

    wpsolr
    Keymaster
    3 years, 11 months ago #19853

    You mean: added_post_meta, updated_post_meta, deleted_post_meta ?

    dnikola
    Participant
    3 years, 11 months ago #19854

    no I mean to hook on save post action for custom post type’s

    for example

    custom_post === test

    add_action( ‘save_post_test’, ‘my_update_user_meta_function’, 10, 3 );

    wpsolr
    Keymaster
    3 years, 11 months ago #19855

    Do you trigger action ‘save_post_test’ manually?

    dnikola
    Participant
    3 years, 9 months ago #20727

    Ok I made test’s and it appear that tringering insert post to update meta is very expensive operation

    update_post_meta takes no more than 0.001 sec or less but updating post takes from 1 to 2 sec.

    imagine how much is that time for 1000 post in one pass…

    so i ended with updating field in elasticsearch and post_meta fields, but you should consider to add trigger when post meta is updated…

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.