index post meta on update
-
dnikolaParticipant3 years ago #19819
Hi Patrice,
I have situation where with cron job a do some query’s and put results as ID’s in post meta field.
so we use update_post_meta function, that works like expected, but WPsolr doesn’t detected changes on post.So I come with possible solution, initiate wp_post_update function on update_post_meta / but this is expensive call on large database where possible 1000 inserts can be done at some moments and i would like to avoid it, and question is will that work 🙂
Second possible solution is to insert this data directly also for Elasticsearch at same moment when post meta is updated
Third possible solution is to hook with your plugin and to do something.
What you can suggest me?
Regards!
wpsolrKeymaster3 years ago #19838Yes, 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.
dnikolaParticipant3 years ago #19850I 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 :/dnikolaParticipant2 years, 11 months ago #20727Ok 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…
You must be logged in to reply to this topic.