From e164fa45e0a24954c4784e2fe6d2b94347e45b7c Mon Sep 17 00:00:00 2001 From: Helmut Januschka Date: Fri, 18 Jan 2019 11:22:53 +0100 Subject: [PATCH] ep bulk timeout increase --- src/Core.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Core.php b/src/Core.php index 0431308..e4d6475 100644 --- a/src/Core.php +++ b/src/Core.php @@ -26,6 +26,13 @@ public function add_filters() { } + public function ep_bulk_index_posts_request_args($args, $body) + { + $args['timeout'] = 300000; + + return $args; + } + public function add_actions() { //Disable ACF fields that are from DB - improves performance a lot @@ -45,6 +52,11 @@ public function add_actions() add_filter('ep_formatted_args', [$this, 'ep_formatted_args'], 1, 1); add_filter('ep_index_post_request_args', [$this, 'ep_index_post_request_args'], 1, 2); add_filter('ep_index_post_request_path', [$this, 'ep_index_post_request_path'], 1, 2); + add_filter('ep_bulk_index_posts_request_args', [$this, 'ep_bulk_index_posts_request_args'], 10, 2); + + //workaround: https://github.com/10up/ElasticPress/pull/1158 + add_filter('ep_post_sync_args', [$this, 'ep_post_sync_args'], 10, 2); + /// ELASITC PRESS add_filter('acp/filtering/cache/seconds', function ($seconds) { @@ -104,6 +116,14 @@ public function add_actions() }); } + public function ep_post_sync_args($args, $post_id) + { + $args['comment_status'] = absint($args['comment_status']); + $args['ping_status'] = absint($args['ping_status']); + + return $args; + } + //ACF querie disable // public function debug_enabled() @@ -184,10 +204,10 @@ public function ep_formatted_args($args) $new['query_string'] = $new['multi_match']; $new['query_string']['query'] = $this->wildCardIt($new['query_string']['query']); $new['query_string']['query'] = str_replace( - ['\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '?', ':'], - ['\\\\', "\+", "\-", "\&", "\|", "\!", "\(", "\)", "\{", "\}", "\[", "\]", "\^", "\~", "\?", "\:"], - $new['query_string']['query'] - ); + ['\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '?', ':'], + ['\\\\', "\+", "\-", "\&", "\|", "\!", "\(", "\)", "\{", "\}", "\[", "\]", "\^", "\~", "\?", "\:"], + $new['query_string']['query'] + ); $new['query_string']['analyze_wildcard'] = true; unset($new['query_string']['type']); $new['query_string']['fields'] = ['post_title'];