Changeset 3147520
- Timestamp:
- 09/06/2024 11:04:22 AM (18 months ago)
- Location:
- atlas-search
- Files:
-
- 12 added
- 6 deleted
- 32 edited
- 1 copied
-
tags/0.2.57 (copied) (copied from atlas-search/trunk)
-
tags/0.2.57/.yarn (added)
-
tags/0.2.57/.yarn/install-state.gz (added)
-
tags/0.2.57/README.txt (modified) (2 diffs)
-
tags/0.2.57/atlas-search.php (modified) (2 diffs)
-
tags/0.2.57/commands/class-wpe-content-engine-sync-data.php (modified) (3 diffs)
-
tags/0.2.57/helper/api/sync-data/sync-data-controller.php (modified) (4 diffs)
-
tags/0.2.57/helper/exceptions/client-query-exception.php (modified) (1 diff)
-
tags/0.2.57/helper/multisite-network-sync.php (modified) (2 diffs)
-
tags/0.2.57/helper/sync/batches/custom-post-type.php (modified) (1 diff)
-
tags/0.2.57/helper/sync/batches/options/batch-options.php (modified) (1 diff)
-
tags/0.2.57/helper/sync/batches/page.php (modified) (3 diffs)
-
tags/0.2.57/helper/sync/batches/post.php (modified) (3 diffs)
-
tags/0.2.57/helper/sync/graphql/client.php (modified) (1 diff)
-
tags/0.2.57/includes/class-wpe-content-engine.php (modified) (1 diff)
-
tags/0.2.57/includes/smart-search-settings/build/asset-manifest.json (modified) (2 diffs)
-
tags/0.2.57/includes/smart-search-settings/build/index.html (modified) (1 diff)
-
tags/0.2.57/includes/smart-search-settings/build/static/js/main.2259e6a0.js (added)
-
tags/0.2.57/includes/smart-search-settings/build/static/js/main.2259e6a0.js.LICENSE.txt (added)
-
tags/0.2.57/includes/smart-search-settings/build/static/js/main.2259e6a0.js.map (added)
-
tags/0.2.57/includes/smart-search-settings/build/static/js/main.d2b1874d.js (deleted)
-
tags/0.2.57/includes/smart-search-settings/build/static/js/main.d2b1874d.js.LICENSE.txt (deleted)
-
tags/0.2.57/includes/smart-search-settings/build/static/js/main.d2b1874d.js.map (deleted)
-
tags/0.2.57/src/index/batch.php (added)
-
tags/0.2.57/src/index/post.php (modified) (4 diffs)
-
tags/0.2.57/src/query/meta.php (modified) (1 diff)
-
trunk/.yarn (added)
-
trunk/.yarn/install-state.gz (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/atlas-search.php (modified) (2 diffs)
-
trunk/commands/class-wpe-content-engine-sync-data.php (modified) (3 diffs)
-
trunk/helper/api/sync-data/sync-data-controller.php (modified) (4 diffs)
-
trunk/helper/exceptions/client-query-exception.php (modified) (1 diff)
-
trunk/helper/multisite-network-sync.php (modified) (2 diffs)
-
trunk/helper/sync/batches/custom-post-type.php (modified) (1 diff)
-
trunk/helper/sync/batches/options/batch-options.php (modified) (1 diff)
-
trunk/helper/sync/batches/page.php (modified) (3 diffs)
-
trunk/helper/sync/batches/post.php (modified) (3 diffs)
-
trunk/helper/sync/graphql/client.php (modified) (1 diff)
-
trunk/includes/class-wpe-content-engine.php (modified) (1 diff)
-
trunk/includes/smart-search-settings/build/asset-manifest.json (modified) (2 diffs)
-
trunk/includes/smart-search-settings/build/index.html (modified) (1 diff)
-
trunk/includes/smart-search-settings/build/static/js/main.2259e6a0.js (added)
-
trunk/includes/smart-search-settings/build/static/js/main.2259e6a0.js.LICENSE.txt (added)
-
trunk/includes/smart-search-settings/build/static/js/main.2259e6a0.js.map (added)
-
trunk/includes/smart-search-settings/build/static/js/main.d2b1874d.js (deleted)
-
trunk/includes/smart-search-settings/build/static/js/main.d2b1874d.js.LICENSE.txt (deleted)
-
trunk/includes/smart-search-settings/build/static/js/main.d2b1874d.js.map (deleted)
-
trunk/src/index/batch.php (added)
-
trunk/src/index/post.php (modified) (4 diffs)
-
trunk/src/query/meta.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
atlas-search/tags/0.2.57/README.txt
r3143797 r3147520 3 3 Tested up to: 6.6 4 4 Requires PHP: 7.4 5 Stable tag: 0.2.5 65 Stable tag: 0.2.57 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 48 48 49 49 == Changelog == 50 = 0.2.57 = 51 * **Added:** Bulk indexing support. 52 * **Updated:** wp-cli command which now takes into account multisite 53 * **Added:** Improved WP_Meta_Query mappings for the LIKE operator. 54 50 55 = 0.2.56 = 51 56 * **Added:** WP_Meta_Query support. -
atlas-search/tags/0.2.57/atlas-search.php
r3143797 r3147520 16 16 * Plugin URI: https://developers.wpengine.com/ 17 17 * Description: Searching WordPress data with WP Engine Smart Search. 18 * Version: 0.2.5 618 * Version: 0.2.57 19 19 * Author: WP Engine 20 20 * Author URI: https://wpengine.com/ … … 41 41 * Rename this for your plugin and update it as you release new versions. 42 42 */ 43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.5 6' );43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.57' ); 44 44 45 45 /** -
atlas-search/tags/0.2.57/commands/class-wpe-content-engine-sync-data.php
r3075724 r3147520 5 5 } 6 6 7 use Wpe_Content_Engine\Core_Wp_Wrapper\Wp_Progress_Bar; 8 use Wpe_Content_Engine\Helper\Progress_Bar_Info_Trait; 9 use Wpe_Content_Engine\Helper\Sync\Batches\Batch_Sync_Factory; 10 use Wpe_Content_Engine\Helper\Sync\Batches\Options\Batch_Options; 11 use Wpe_Content_Engine\Helper\Sync\Batches\Options\Resume_Options; 12 use Wpe_Content_Engine\Helper\Sync\Batches\Sync_Lock_Manager; 13 use Wpe_Content_Engine\Helper\Sync\Batches\Batch_Sync_Interface; 14 use const AtlasSearch\Index\MANUAL_INDEX; 15 use const Wpe_Content_Engine\Helper\Notifications\WPE_CONTENT_ENGINE_RE_SYNC_HAS_OCCURRED; 16 17 // @codingStandardsIgnoreStart 7 use Wpe_Content_Engine\WPSettings; 18 8 19 9 /** … … 21 11 */ 22 12 class Wpe_Content_Engine_Sync_Data { 23 13 private $start_time; 24 14 /** 25 15 * Syncs all data to Smart Search. 26 16 * 27 17 * ## EXAMPLES 28 * wp wpe-smart-search sync-data --size=10 --no-resume29 * or30 18 * wp wpe-smart-search sync-data 31 19 * or 32 20 * wp wpe-smart-search sync-data --reset 33 *34 * [--size=<batch-size>]35 * : Used to sync ALL data in batches of <batch-size>. Batch size should be a positive integer.36 * If is set to a very big integer the system might run out of memory or fail to sync all data.37 * If no value is specified then defaults to 2038 *39 * [--no-resume]40 * : Start sync from the start and not from last error41 * default: true42 21 * 43 22 * [--reset] … … 45 24 * default: false 46 25 * 26 * [--site-id] 27 * : Site ID to sync data for 28 * default: current site or network admin if in multi-site mode 29 * options: <site-id> | network 30 * 47 31 * @subcommand sync-data 48 32 * @when after_wp_load 49 33 * 34 * @param array $args Command arguments. 35 * @param array $assoc_args Command associative arguments. 50 36 */ 37 public function _sync_data( $args, $assoc_args ) { 38 try { 39 $this->start_time = time(); 40 $client = new \Wpe_Content_Engine\Helper\Sync\GraphQL\Client( Wpe_Content_Engine::get_plugin_name(), Wpe_Content_Engine::get_version() ); 41 $controller = new \Wpe_Content_Engine\Helper\API\Sync_Data\Sync_Data_Controller( $client, new WPSettings() ); 51 42 52 public function _sync_data( $args, $assoc_args ) { 53 $batch_size = (int) ( $assoc_args['size'] ?? Batch_Options::DEFAULT_BATCH_SIZE ); 43 $reset = $assoc_args['reset'] ?? false; 44 if ( $reset ) { 45 WP_CLI::line( 'Clearing all data.' ); 46 $result = $controller->delete_sync_data( new WP_REST_Request( 'DELETE' ) ); 47 if ( 200 !== $result->status ) { 48 WP_CLI::error( 'Failed to clear data.' ); 49 } 50 WP_CLI::line( $result->data['message'] ); 51 } 54 52 55 if ( $batch_size <= 0 ) { 56 WP_CLI::error( 'Batch size should be an integer greater than zero' ); 57 return; 53 $site_id_arg = $assoc_args['site-id'] ?? false; 54 $site_id = $this->parse_site_id( $site_id_arg ); 55 $uuid = ''; 56 /** 57 * @var \Wpe_Content_Engine\Helper\API\Sync_Data\Response $result 58 */ 59 $result = $this->perform_index( $controller, $uuid, $site_id ); 60 61 $this->display_progress_bar( $result->message ?? '', $result->progress, 100 ); 62 63 while ( \Wpe_Content_Engine\Helper\Constants\Sync_Response_Status::PENDING === $result->status ) { 64 $result = $this->perform_index( $controller, $result->uuid, $site_id ); 65 if ( \Wpe_Content_Engine\Helper\Constants\Sync_Response_Status::COMPLETED === $result->status ) { 66 break; 67 } else { 68 $this->display_progress_bar( $result->message ?? '', $result->progress, 100 ); 69 } 70 } 71 WP_CLI::log( "\r\nIndexing completed!" ); 72 } catch ( \Exception $e ) { 73 WP_CLI::error( $e->getMessage() ); 74 } 75 } 76 77 private function perform_index( $controller, $uuid, $site_id ) { 78 $rest_request = new WP_REST_Request( 'POST', '/wpe-content-engine/v1/sync-data' ); 79 $rest_request->set_body( 80 wp_json_encode( 81 array( 82 'uuid' => $uuid, 83 'siteId' => $site_id, 84 ) 85 ) 86 ); 87 $rest_request->set_headers( 88 array( 89 'Content-Type' => 'application/json', 90 ), 91 ); 92 return $controller->sync_data( $rest_request ); 93 } 94 95 private function parse_site_id( $site_id ) { 96 if ( 'network' === $site_id ) { 97 return \AtlasSearch\Support\WordPress\NETWORK_ADMIN; 98 } elseif ( $site_id ) { 99 return $site_id; 100 } elseif ( is_multisite() ) { 101 return \AtlasSearch\Support\WordPress\NETWORK_ADMIN; 102 } else { 103 return (string) get_current_blog_id(); 104 } 105 } 106 107 private function display_progress_bar( string $message, int $current, int $total, int $length = 50 ) { 108 if ( 0 === $current ) { 109 $current = 1; 58 110 } 59 111 60 $ with_reset = $assoc_args['reset'] ?? false;61 $ with_resume = $assoc_args['resume'] ?? true;112 $percent = floor( ( $current * 100 ) / $total ); 113 $progress_bar = floor( ( $length * $percent ) / 100 ); 62 114 63 $batch_options = new Batch_Options( 64 $batch_size, 65 1, 66 Batch_Sync_Factory::DATA_TO_SYNC, 67 array( get_current_blog_id() ) 115 // Calculate elapsed time. 116 $elapsed_time = time() - $this->start_time; 117 118 // Estimate remaining time. 119 $estimated_total_time = ( $elapsed_time / $current ) * $total; 120 $remaining_time = $estimated_total_time - $elapsed_time; 121 122 // Format remaining time. 123 $remaining_minutes = floor( $remaining_time / 60 ); 124 $remaining_seconds = $remaining_time % 60; 125 $remaining_time_formatted = sprintf( '%02d:%02d', $remaining_minutes, $remaining_seconds ); 126 127 printf( 128 " %s%% [%s>%s] %s/%s | ETA: %s | %s\r", 129 esc_html( $percent ), 130 esc_html( str_repeat( '=', $progress_bar ) ), 131 esc_html( str_repeat( ' ', $length - $progress_bar ) ), 132 esc_html( $current ), 133 esc_html( $total ), 134 esc_html( $remaining_time_formatted ), 135 esc_html( $message . str_repeat( ' ', 20 ) ), 68 136 ); 137 } 69 138 70 /** @var Resume_Options|null $resume_options */ 71 $resume_options = get_option( Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME, null ); 139 } 72 140 73 if ( $with_resume && !$with_reset && !empty( $resume_options ) && ( $resume_options instanceof Resume_Options ) ) {74 $batch_options->calculate_with_resume( $resume_options );75 76 WP_CLI::log(77 "Resume started! Starting with these parameters --> Table:{$resume_options->get_entity()}, "78 . " Page: {$batch_options->get_page()}, Batch Size: {$batch_options->get_batch_size()}"79 );80 }81 82 $sync_lock_manager = new Sync_Lock_Manager();83 $uuid = null;84 85 try {86 $time_start = new DateTime();87 $start = microtime(true);88 89 $moment = new DateTime();90 $can_start = $sync_lock_manager->can_start( $moment );91 $cannot_start_text = !$can_start ? 'yes' : 'no';92 WP_CLI::log( "Init check, lock present: {$cannot_start_text}" );93 94 if ( $can_start ) {95 // activate96 WP_CLI::log( "No lock present, starting sync..." );97 $uuid = $sync_lock_manager->start( $moment, null );98 WP_CLI::log( "Sync lock acquired. Sync lock ID: {$uuid}" );99 }100 else {101 WP_CLI::log( "Lock active! Cannot start a new sync! Exiting..." );102 return;103 }104 105 delete_option( Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME );106 107 if ( $with_reset ) {108 WP_CLI::log( "'--reset' flag was provided. Deleting all.");109 \AtlasSearch\Index\delete_all( MANUAL_INDEX );110 }111 112 foreach ( $batch_options->get_data_to_be_synced() as $short_name => $class ) {113 114 /** @var Batch_Sync_Interface| Progress_Bar_Info_Trait $obj ,115 * @var string $class116 */117 $obj = Batch_Sync_Factory::build( $class );118 $page = $batch_options->get_page();119 WP_CLI::log( "Sync started : {$short_name}" );120 121 do {122 try {123 $items = $obj->get_items( $page, $batch_size );124 125 if ( empty( $items ) ) {126 continue;127 }128 129 $obj->format_items( $items, $page );130 $obj->set_progress_bar( new Wp_Progress_Bar( count( $items ) ) );131 $obj->sync( $items );132 $page ++;133 } catch ( ErrorException $e ) {134 WP_CLI::error( "Something went wrong. Error message: {$e->getMessage()}", false );135 } finally {136 update_option(137 Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME,138 new Resume_Options( $short_name, $batch_size, $page )139 );140 141 if ( isset( $e ) && ( $e instanceof ErrorException ) ) {142 /** @var ErrorException|null $e */143 throw $e;144 }145 }146 } while ( count( $items ) >= $batch_size );147 148 $batch_options->set_page( 1 );149 150 WP_CLI::log(151 empty( $obj->get_items( 1, $batch_size ) ) ? "No {$short_name} data to sync" : "Sync Success: {$short_name}"152 );153 154 update_option( WPE_CONTENT_ENGINE_RE_SYNC_HAS_OCCURRED, true );155 }156 157 delete_option( Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME );158 WP_CLI::log( 'Success syncing all data' );159 160 $fd = ( new DateTime() )->diff( $time_start );161 WP_CLI::log( WP_CLI::colorize( "%GTotal time: {$fd->format('%H:%i:%s.%f')}%n " ) );162 } catch ( ErrorException $e ) {163 WP_CLI::error( "There was an error during sync. Error message: {$e->getMessage()}", false );164 }165 finally {166 // make sure that we always release the lock if we acquired one this run.167 if ( !empty( $uuid ) ) {168 $moment = new DateTime();169 $sync_lock_manager->finish( $moment, $uuid );170 WP_CLI::log( "Sync lock ID {$uuid} released!" );171 }172 else {173 WP_CLI::log( 'No sync lock acquired this run.!' );174 }175 }176 }177 }178 141 WP_CLI::add_command( 'wpe-smart-search', 'Wpe_Content_Engine_Sync_Data' ); 179 180 // @codingStandardsIgnoreEnd -
atlas-search/tags/0.2.57/helper/api/sync-data/sync-data-controller.php
r3116529 r3147520 106 106 $site_ids = $this->get_site_ids( \AtlasSearch\Support\WordPress\NETWORK_ADMIN === $json['siteId'] ); 107 107 $batch_options = new Batch_Options( 108 Batch_Options::DEFAULT_BATCH_SIZE,108 \AtlasSearch\Index\get_batch_size(), 109 109 1, 110 110 Batch_Sync_Factory::DATA_TO_SYNC, … … 290 290 $obj = Batch_Sync_Factory::build( $current_data['class'], \AtlasSearch\Support\WordPress\NETWORK_ADMIN === $json['siteId'], $site_id ); 291 291 $page = $batch_options->get_page(); 292 $items = $obj->get_items( $page, Batch_Options::DEFAULT_BATCH_SIZE);292 $items = $obj->get_items( $page, \AtlasSearch\Index\get_batch_size() ); 293 293 } 294 294 … … 333 333 \AtlasSearch\Support\WordPress\update_option( 334 334 Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME, 335 new Resume_Options( $next_short_name, Batch_Options::DEFAULT_BATCH_SIZE, 1, $site_id, $progress )335 new Resume_Options( $next_short_name, \AtlasSearch\Index\get_batch_size(), 1, $site_id, $progress ) 336 336 ); 337 337 … … 362 362 \AtlasSearch\Support\WordPress\update_option( 363 363 Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME, 364 new Resume_Options( $short_name, Batch_Options::DEFAULT_BATCH_SIZE, $page, $batch_options->get_current_site_id(), $progress )364 new Resume_Options( $short_name, \AtlasSearch\Index\get_batch_size(), $page, $batch_options->get_current_site_id(), $progress ) 365 365 ); 366 366 -
atlas-search/tags/0.2.57/helper/exceptions/client-query-exception.php
r3029933 r3147520 5 5 class ClientQueryException extends \ErrorException {} 6 6 7 class ClientQueryGraphqlErrorsException extends ClientQueryException {} 7 class ClientQueryGraphqlErrorsException extends ClientQueryException { 8 public function is_access_ai_powered_search_error(): bool { 9 return strpos( $this->getMessage(), 'To access this feature, you must upgrade to AI-Powered Search.' ) !== false; 10 } 11 } -
atlas-search/tags/0.2.57/helper/multisite-network-sync.php
r3075724 r3147520 5 5 use Wpe_Content_Engine\Helper\Sync\Batches\Batch_Sync_Interface; 6 6 7 use const AtlasSearch\Index\BULK_INDEX_GRAPHQL; 8 use const AtlasSearch\Index\MANUAL_INDEX; 9 7 10 abstract class Multisite_Network_Sync implements Batch_Sync_Interface { 11 use Progress_Bar_Info_Trait; 8 12 9 13 /** … … 34 38 */ 35 39 abstract protected function _get_items( $offset, $number ); 36 abstract protected function _sync( $items ); 40 41 private function bulk_sync( $posts ) { 42 $this->tick(); 43 \AtlasSearch\Index\bulk_index_posts( $posts ); 44 $this->finish(); 45 } 46 47 protected function _sync( $posts ) { 48 if ( count( $posts ) <= 0 ) { 49 return; 50 } 51 52 $this->bulk_sync( $posts ); 53 } 37 54 38 55 /** -
atlas-search/tags/0.2.57/helper/sync/batches/custom-post-type.php
r3075724 r3147520 40 40 } 41 41 42 /**43 * @param WP_Post[] $custom_post_type_posts WordPress custom post types that are flagged to be showed in graphql.44 *45 * @throws ErrorException Exception.46 */47 protected function _sync( $custom_post_type_posts ) {48 if ( count( $custom_post_type_posts ) <= 0 ) {49 return;50 }51 52 foreach ( $custom_post_type_posts as $cpt_post ) {53 \AtlasSearch\Index\index_post( $cpt_post, $cpt_post->ID, \AtlasSearch\Index\MANUAL_INDEX );54 $this->tick();55 }56 $this->finish();57 }58 42 59 43 /** -
atlas-search/tags/0.2.57/helper/sync/batches/options/batch-options.php
r3075724 r3147520 15 15 * @var int 16 16 */ 17 public const DEFAULT_BATCH_SIZE = 20;17 public const DEFAULT_BATCH_SIZE = 10; 18 18 19 19 /** -
atlas-search/tags/0.2.57/helper/sync/batches/page.php
r3075724 r3147520 3 3 namespace Wpe_Content_Engine\Helper\Sync\Batches; 4 4 5 use ErrorException;6 5 use WP_CLI; 7 6 use WP_Query; … … 14 13 use Wpe_Content_Engine\Helper\Progress_Bar_Info_Trait; 15 14 16 use const AtlasSearch\Index\MANUAL_INDEX;17 15 18 16 class Page extends Multisite_Network_Sync { … … 41 39 42 40 /** 43 * @param WP_Post[] $pages Pages.44 *45 * @throws ErrorException Exception.46 */47 protected function _sync( $pages ) {48 if ( count( $pages ) <= 0 ) {49 return;50 }51 52 foreach ( $pages as $page ) {53 \AtlasSearch\Index\index_post( $page, $page->ID, MANUAL_INDEX );54 $this->tick();55 }56 $this->finish();57 }58 59 /**60 41 * @param mixed $items Items. 61 42 * @param mixed $page Page. -
atlas-search/tags/0.2.57/helper/sync/batches/post.php
r3075724 r3147520 3 3 namespace Wpe_Content_Engine\Helper\Sync\Batches; 4 4 5 use ErrorException;6 5 use WP_CLI; 7 6 use WP_Query; … … 11 10 use Wpe_Content_Engine\Helper\Multisite_Network_Sync; 12 11 use Wpe_Content_Engine\Helper\Progress_Bar_Info_Trait; 13 14 use const AtlasSearch\Index\MANUAL_INDEX;15 12 16 13 class Post extends Multisite_Network_Sync { … … 36 33 } 37 34 38 /**39 * @param WP_Post[] $posts Posts.40 *41 * @throws ErrorException Exception.42 */43 protected function _sync( $posts ) {44 if ( count( $posts ) <= 0 ) {45 return;46 }47 48 foreach ( $posts as $post ) {49 \AtlasSearch\Index\index_post( $post, $post->ID, MANUAL_INDEX );50 $this->tick();51 52 }53 $this->finish();54 }55 35 56 36 /** -
atlas-search/tags/0.2.57/helper/sync/graphql/client.php
r3042698 r3147520 100 100 array( 101 101 'headers' => $headers, 102 'timeout' => 20,102 'timeout' => 30, 103 103 'ignore_errors' => true, 104 104 'body' => wp_json_encode( -
atlas-search/tags/0.2.57/includes/class-wpe-content-engine.php
r3143797 r3147520 225 225 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/index/post.php'; 226 226 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/index/semantic-search.php'; 227 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/index/batch.php'; 227 228 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/hooks/filters.php'; 228 229 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/migrations/rename-post-keys-config.php'; -
atlas-search/tags/0.2.57/includes/smart-search-settings/build/asset-manifest.json
r3143797 r3147520 2 2 "files": { 3 3 "main.css": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css", 4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main. d2b1874d.js",4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.2259e6a0.js", 5 5 "static/media/wpengine-logo.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/wpengine-logo.40f3a1215fbea4708a6a4bff9624fece.svg", 6 6 "static/media/content-copy.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/content-copy.e50f17791e757794684afc63d5d4cb00.svg", … … 18 18 "index.html": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/index.html", 19 19 "main.751d9a0b.css.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css.map", 20 "main. d2b1874d.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.d2b1874d.js.map"20 "main.2259e6a0.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.2259e6a0.js.map" 21 21 }, 22 22 "entrypoints": [ 23 23 "static/css/main.751d9a0b.css", 24 "static/js/main. d2b1874d.js"24 "static/js/main.2259e6a0.js" 25 25 ] 26 26 } -
atlas-search/tags/0.2.57/includes/smart-search-settings/build/index.html
r3143797 r3147520 1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main. d2b1874d.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css" rel="stylesheet"></head>1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.2259e6a0.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css" rel="stylesheet"></head> -
atlas-search/tags/0.2.57/src/index/post.php
r3143797 r3147520 47 47 GRAPHQL; 48 48 49 const BULK_INDEX_GRAPHQL = <<<'GRAPHQL' 50 mutation BulkIndex($docs: [DocumentInput!], $meta: MetaInput) { 51 bulkIndex(input: { 52 documents: $docs 53 meta: $meta 54 }) { 55 code 56 } 57 } 58 GRAPHQL; 59 49 60 50 61 function format_date( $date ) { … … 64 75 */ 65 76 function index_post( WP_Post $post, int $post_id, string $index_type = AUTOMATIC_INDEX ) { 66 // bring the blocking states. 77 $data = prepare_post( $post, $post_id, $index_type ); 78 79 if ( false === $data ) { 80 return false; 81 } 82 return graphql( INDEX_GRAPHQL, $data ); 83 } 84 85 /** 86 * Indexes a list of WP_Posts 87 * 88 * @param WP_Post[] $posts The posts. 89 * @return mixed 90 */ 91 function bulk_index_posts( $posts ) { 92 $posts_to_index = array(); 93 94 foreach ( $posts as $post ) { 95 $posts_to_index[] = prepare_post( $post, $post->ID, MANUAL_INDEX )['input']; 96 } 97 98 // Index the posts. 99 $variables = array( 100 'docs' => $posts_to_index, 101 'meta' => array( 102 'system' => \AtlasSearch\Meta\get_system_version(), 103 'action' => MANUAL_INDEX . ':bulk-index:' . $post->post_type . ':count=' . count( $posts_to_index ), 104 'source' => \AtlasSearch\Meta\get_domain_name(), 105 ), 106 ); 107 108 return graphql( BULK_INDEX_GRAPHQL, $variables ); 109 } 110 111 /** 112 * Prepare a post for indexing. 113 * 114 * @param WP_Post $post The post. 115 * @param int $post_id The post id. 116 * @param string $index_type The index operation type. 117 * @return array|bool 118 */ 119 function prepare_post( WP_Post $post, int $post_id, string $index_type = AUTOMATIC_INDEX ) { 67 120 if ( false === is_allowed( $post ) ) { 68 121 return false; … … 98 151 $post_array = \AtlasSearch\Hooks\filter_extra_fields( $post_array, $post ); 99 152 100 $variables =array(153 return array( 101 154 'input' => array( 102 155 'id' => \AtlasSearch\Hooks\filter_index_id( $post->post_type, $post_id ), … … 109 162 ), 110 163 ); 111 112 return graphql( INDEX_GRAPHQL, $variables );113 164 } 114 165 -
atlas-search/tags/0.2.57/src/query/meta.php
r3143797 r3147520 141 141 142 142 if ( 'LIKE' === $compare || 'NOT LIKE' === $compare ) { 143 return '*' . $value . '*'; 143 switch ( str_word_count( $value ) ) { 144 case 1: 145 return '*' . $value . '*'; 146 default: 147 return '"*' . $value . '*"'; 148 } 144 149 } 145 150 -
atlas-search/trunk/README.txt
r3143797 r3147520 3 3 Tested up to: 6.6 4 4 Requires PHP: 7.4 5 Stable tag: 0.2.5 65 Stable tag: 0.2.57 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 48 48 49 49 == Changelog == 50 = 0.2.57 = 51 * **Added:** Bulk indexing support. 52 * **Updated:** wp-cli command which now takes into account multisite 53 * **Added:** Improved WP_Meta_Query mappings for the LIKE operator. 54 50 55 = 0.2.56 = 51 56 * **Added:** WP_Meta_Query support. -
atlas-search/trunk/atlas-search.php
r3143797 r3147520 16 16 * Plugin URI: https://developers.wpengine.com/ 17 17 * Description: Searching WordPress data with WP Engine Smart Search. 18 * Version: 0.2.5 618 * Version: 0.2.57 19 19 * Author: WP Engine 20 20 * Author URI: https://wpengine.com/ … … 41 41 * Rename this for your plugin and update it as you release new versions. 42 42 */ 43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.5 6' );43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.57' ); 44 44 45 45 /** -
atlas-search/trunk/commands/class-wpe-content-engine-sync-data.php
r3075724 r3147520 5 5 } 6 6 7 use Wpe_Content_Engine\Core_Wp_Wrapper\Wp_Progress_Bar; 8 use Wpe_Content_Engine\Helper\Progress_Bar_Info_Trait; 9 use Wpe_Content_Engine\Helper\Sync\Batches\Batch_Sync_Factory; 10 use Wpe_Content_Engine\Helper\Sync\Batches\Options\Batch_Options; 11 use Wpe_Content_Engine\Helper\Sync\Batches\Options\Resume_Options; 12 use Wpe_Content_Engine\Helper\Sync\Batches\Sync_Lock_Manager; 13 use Wpe_Content_Engine\Helper\Sync\Batches\Batch_Sync_Interface; 14 use const AtlasSearch\Index\MANUAL_INDEX; 15 use const Wpe_Content_Engine\Helper\Notifications\WPE_CONTENT_ENGINE_RE_SYNC_HAS_OCCURRED; 16 17 // @codingStandardsIgnoreStart 7 use Wpe_Content_Engine\WPSettings; 18 8 19 9 /** … … 21 11 */ 22 12 class Wpe_Content_Engine_Sync_Data { 23 13 private $start_time; 24 14 /** 25 15 * Syncs all data to Smart Search. 26 16 * 27 17 * ## EXAMPLES 28 * wp wpe-smart-search sync-data --size=10 --no-resume29 * or30 18 * wp wpe-smart-search sync-data 31 19 * or 32 20 * wp wpe-smart-search sync-data --reset 33 *34 * [--size=<batch-size>]35 * : Used to sync ALL data in batches of <batch-size>. Batch size should be a positive integer.36 * If is set to a very big integer the system might run out of memory or fail to sync all data.37 * If no value is specified then defaults to 2038 *39 * [--no-resume]40 * : Start sync from the start and not from last error41 * default: true42 21 * 43 22 * [--reset] … … 45 24 * default: false 46 25 * 26 * [--site-id] 27 * : Site ID to sync data for 28 * default: current site or network admin if in multi-site mode 29 * options: <site-id> | network 30 * 47 31 * @subcommand sync-data 48 32 * @when after_wp_load 49 33 * 34 * @param array $args Command arguments. 35 * @param array $assoc_args Command associative arguments. 50 36 */ 37 public function _sync_data( $args, $assoc_args ) { 38 try { 39 $this->start_time = time(); 40 $client = new \Wpe_Content_Engine\Helper\Sync\GraphQL\Client( Wpe_Content_Engine::get_plugin_name(), Wpe_Content_Engine::get_version() ); 41 $controller = new \Wpe_Content_Engine\Helper\API\Sync_Data\Sync_Data_Controller( $client, new WPSettings() ); 51 42 52 public function _sync_data( $args, $assoc_args ) { 53 $batch_size = (int) ( $assoc_args['size'] ?? Batch_Options::DEFAULT_BATCH_SIZE ); 43 $reset = $assoc_args['reset'] ?? false; 44 if ( $reset ) { 45 WP_CLI::line( 'Clearing all data.' ); 46 $result = $controller->delete_sync_data( new WP_REST_Request( 'DELETE' ) ); 47 if ( 200 !== $result->status ) { 48 WP_CLI::error( 'Failed to clear data.' ); 49 } 50 WP_CLI::line( $result->data['message'] ); 51 } 54 52 55 if ( $batch_size <= 0 ) { 56 WP_CLI::error( 'Batch size should be an integer greater than zero' ); 57 return; 53 $site_id_arg = $assoc_args['site-id'] ?? false; 54 $site_id = $this->parse_site_id( $site_id_arg ); 55 $uuid = ''; 56 /** 57 * @var \Wpe_Content_Engine\Helper\API\Sync_Data\Response $result 58 */ 59 $result = $this->perform_index( $controller, $uuid, $site_id ); 60 61 $this->display_progress_bar( $result->message ?? '', $result->progress, 100 ); 62 63 while ( \Wpe_Content_Engine\Helper\Constants\Sync_Response_Status::PENDING === $result->status ) { 64 $result = $this->perform_index( $controller, $result->uuid, $site_id ); 65 if ( \Wpe_Content_Engine\Helper\Constants\Sync_Response_Status::COMPLETED === $result->status ) { 66 break; 67 } else { 68 $this->display_progress_bar( $result->message ?? '', $result->progress, 100 ); 69 } 70 } 71 WP_CLI::log( "\r\nIndexing completed!" ); 72 } catch ( \Exception $e ) { 73 WP_CLI::error( $e->getMessage() ); 74 } 75 } 76 77 private function perform_index( $controller, $uuid, $site_id ) { 78 $rest_request = new WP_REST_Request( 'POST', '/wpe-content-engine/v1/sync-data' ); 79 $rest_request->set_body( 80 wp_json_encode( 81 array( 82 'uuid' => $uuid, 83 'siteId' => $site_id, 84 ) 85 ) 86 ); 87 $rest_request->set_headers( 88 array( 89 'Content-Type' => 'application/json', 90 ), 91 ); 92 return $controller->sync_data( $rest_request ); 93 } 94 95 private function parse_site_id( $site_id ) { 96 if ( 'network' === $site_id ) { 97 return \AtlasSearch\Support\WordPress\NETWORK_ADMIN; 98 } elseif ( $site_id ) { 99 return $site_id; 100 } elseif ( is_multisite() ) { 101 return \AtlasSearch\Support\WordPress\NETWORK_ADMIN; 102 } else { 103 return (string) get_current_blog_id(); 104 } 105 } 106 107 private function display_progress_bar( string $message, int $current, int $total, int $length = 50 ) { 108 if ( 0 === $current ) { 109 $current = 1; 58 110 } 59 111 60 $ with_reset = $assoc_args['reset'] ?? false;61 $ with_resume = $assoc_args['resume'] ?? true;112 $percent = floor( ( $current * 100 ) / $total ); 113 $progress_bar = floor( ( $length * $percent ) / 100 ); 62 114 63 $batch_options = new Batch_Options( 64 $batch_size, 65 1, 66 Batch_Sync_Factory::DATA_TO_SYNC, 67 array( get_current_blog_id() ) 115 // Calculate elapsed time. 116 $elapsed_time = time() - $this->start_time; 117 118 // Estimate remaining time. 119 $estimated_total_time = ( $elapsed_time / $current ) * $total; 120 $remaining_time = $estimated_total_time - $elapsed_time; 121 122 // Format remaining time. 123 $remaining_minutes = floor( $remaining_time / 60 ); 124 $remaining_seconds = $remaining_time % 60; 125 $remaining_time_formatted = sprintf( '%02d:%02d', $remaining_minutes, $remaining_seconds ); 126 127 printf( 128 " %s%% [%s>%s] %s/%s | ETA: %s | %s\r", 129 esc_html( $percent ), 130 esc_html( str_repeat( '=', $progress_bar ) ), 131 esc_html( str_repeat( ' ', $length - $progress_bar ) ), 132 esc_html( $current ), 133 esc_html( $total ), 134 esc_html( $remaining_time_formatted ), 135 esc_html( $message . str_repeat( ' ', 20 ) ), 68 136 ); 137 } 69 138 70 /** @var Resume_Options|null $resume_options */ 71 $resume_options = get_option( Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME, null ); 139 } 72 140 73 if ( $with_resume && !$with_reset && !empty( $resume_options ) && ( $resume_options instanceof Resume_Options ) ) {74 $batch_options->calculate_with_resume( $resume_options );75 76 WP_CLI::log(77 "Resume started! Starting with these parameters --> Table:{$resume_options->get_entity()}, "78 . " Page: {$batch_options->get_page()}, Batch Size: {$batch_options->get_batch_size()}"79 );80 }81 82 $sync_lock_manager = new Sync_Lock_Manager();83 $uuid = null;84 85 try {86 $time_start = new DateTime();87 $start = microtime(true);88 89 $moment = new DateTime();90 $can_start = $sync_lock_manager->can_start( $moment );91 $cannot_start_text = !$can_start ? 'yes' : 'no';92 WP_CLI::log( "Init check, lock present: {$cannot_start_text}" );93 94 if ( $can_start ) {95 // activate96 WP_CLI::log( "No lock present, starting sync..." );97 $uuid = $sync_lock_manager->start( $moment, null );98 WP_CLI::log( "Sync lock acquired. Sync lock ID: {$uuid}" );99 }100 else {101 WP_CLI::log( "Lock active! Cannot start a new sync! Exiting..." );102 return;103 }104 105 delete_option( Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME );106 107 if ( $with_reset ) {108 WP_CLI::log( "'--reset' flag was provided. Deleting all.");109 \AtlasSearch\Index\delete_all( MANUAL_INDEX );110 }111 112 foreach ( $batch_options->get_data_to_be_synced() as $short_name => $class ) {113 114 /** @var Batch_Sync_Interface| Progress_Bar_Info_Trait $obj ,115 * @var string $class116 */117 $obj = Batch_Sync_Factory::build( $class );118 $page = $batch_options->get_page();119 WP_CLI::log( "Sync started : {$short_name}" );120 121 do {122 try {123 $items = $obj->get_items( $page, $batch_size );124 125 if ( empty( $items ) ) {126 continue;127 }128 129 $obj->format_items( $items, $page );130 $obj->set_progress_bar( new Wp_Progress_Bar( count( $items ) ) );131 $obj->sync( $items );132 $page ++;133 } catch ( ErrorException $e ) {134 WP_CLI::error( "Something went wrong. Error message: {$e->getMessage()}", false );135 } finally {136 update_option(137 Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME,138 new Resume_Options( $short_name, $batch_size, $page )139 );140 141 if ( isset( $e ) && ( $e instanceof ErrorException ) ) {142 /** @var ErrorException|null $e */143 throw $e;144 }145 }146 } while ( count( $items ) >= $batch_size );147 148 $batch_options->set_page( 1 );149 150 WP_CLI::log(151 empty( $obj->get_items( 1, $batch_size ) ) ? "No {$short_name} data to sync" : "Sync Success: {$short_name}"152 );153 154 update_option( WPE_CONTENT_ENGINE_RE_SYNC_HAS_OCCURRED, true );155 }156 157 delete_option( Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME );158 WP_CLI::log( 'Success syncing all data' );159 160 $fd = ( new DateTime() )->diff( $time_start );161 WP_CLI::log( WP_CLI::colorize( "%GTotal time: {$fd->format('%H:%i:%s.%f')}%n " ) );162 } catch ( ErrorException $e ) {163 WP_CLI::error( "There was an error during sync. Error message: {$e->getMessage()}", false );164 }165 finally {166 // make sure that we always release the lock if we acquired one this run.167 if ( !empty( $uuid ) ) {168 $moment = new DateTime();169 $sync_lock_manager->finish( $moment, $uuid );170 WP_CLI::log( "Sync lock ID {$uuid} released!" );171 }172 else {173 WP_CLI::log( 'No sync lock acquired this run.!' );174 }175 }176 }177 }178 141 WP_CLI::add_command( 'wpe-smart-search', 'Wpe_Content_Engine_Sync_Data' ); 179 180 // @codingStandardsIgnoreEnd -
atlas-search/trunk/helper/api/sync-data/sync-data-controller.php
r3116529 r3147520 106 106 $site_ids = $this->get_site_ids( \AtlasSearch\Support\WordPress\NETWORK_ADMIN === $json['siteId'] ); 107 107 $batch_options = new Batch_Options( 108 Batch_Options::DEFAULT_BATCH_SIZE,108 \AtlasSearch\Index\get_batch_size(), 109 109 1, 110 110 Batch_Sync_Factory::DATA_TO_SYNC, … … 290 290 $obj = Batch_Sync_Factory::build( $current_data['class'], \AtlasSearch\Support\WordPress\NETWORK_ADMIN === $json['siteId'], $site_id ); 291 291 $page = $batch_options->get_page(); 292 $items = $obj->get_items( $page, Batch_Options::DEFAULT_BATCH_SIZE);292 $items = $obj->get_items( $page, \AtlasSearch\Index\get_batch_size() ); 293 293 } 294 294 … … 333 333 \AtlasSearch\Support\WordPress\update_option( 334 334 Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME, 335 new Resume_Options( $next_short_name, Batch_Options::DEFAULT_BATCH_SIZE, 1, $site_id, $progress )335 new Resume_Options( $next_short_name, \AtlasSearch\Index\get_batch_size(), 1, $site_id, $progress ) 336 336 ); 337 337 … … 362 362 \AtlasSearch\Support\WordPress\update_option( 363 363 Batch_Options::OPTIONS_WPE_CONTENT_ENGINE_SYNC_RESUME, 364 new Resume_Options( $short_name, Batch_Options::DEFAULT_BATCH_SIZE, $page, $batch_options->get_current_site_id(), $progress )364 new Resume_Options( $short_name, \AtlasSearch\Index\get_batch_size(), $page, $batch_options->get_current_site_id(), $progress ) 365 365 ); 366 366 -
atlas-search/trunk/helper/exceptions/client-query-exception.php
r3029933 r3147520 5 5 class ClientQueryException extends \ErrorException {} 6 6 7 class ClientQueryGraphqlErrorsException extends ClientQueryException {} 7 class ClientQueryGraphqlErrorsException extends ClientQueryException { 8 public function is_access_ai_powered_search_error(): bool { 9 return strpos( $this->getMessage(), 'To access this feature, you must upgrade to AI-Powered Search.' ) !== false; 10 } 11 } -
atlas-search/trunk/helper/multisite-network-sync.php
r3075724 r3147520 5 5 use Wpe_Content_Engine\Helper\Sync\Batches\Batch_Sync_Interface; 6 6 7 use const AtlasSearch\Index\BULK_INDEX_GRAPHQL; 8 use const AtlasSearch\Index\MANUAL_INDEX; 9 7 10 abstract class Multisite_Network_Sync implements Batch_Sync_Interface { 11 use Progress_Bar_Info_Trait; 8 12 9 13 /** … … 34 38 */ 35 39 abstract protected function _get_items( $offset, $number ); 36 abstract protected function _sync( $items ); 40 41 private function bulk_sync( $posts ) { 42 $this->tick(); 43 \AtlasSearch\Index\bulk_index_posts( $posts ); 44 $this->finish(); 45 } 46 47 protected function _sync( $posts ) { 48 if ( count( $posts ) <= 0 ) { 49 return; 50 } 51 52 $this->bulk_sync( $posts ); 53 } 37 54 38 55 /** -
atlas-search/trunk/helper/sync/batches/custom-post-type.php
r3075724 r3147520 40 40 } 41 41 42 /**43 * @param WP_Post[] $custom_post_type_posts WordPress custom post types that are flagged to be showed in graphql.44 *45 * @throws ErrorException Exception.46 */47 protected function _sync( $custom_post_type_posts ) {48 if ( count( $custom_post_type_posts ) <= 0 ) {49 return;50 }51 52 foreach ( $custom_post_type_posts as $cpt_post ) {53 \AtlasSearch\Index\index_post( $cpt_post, $cpt_post->ID, \AtlasSearch\Index\MANUAL_INDEX );54 $this->tick();55 }56 $this->finish();57 }58 42 59 43 /** -
atlas-search/trunk/helper/sync/batches/options/batch-options.php
r3075724 r3147520 15 15 * @var int 16 16 */ 17 public const DEFAULT_BATCH_SIZE = 20;17 public const DEFAULT_BATCH_SIZE = 10; 18 18 19 19 /** -
atlas-search/trunk/helper/sync/batches/page.php
r3075724 r3147520 3 3 namespace Wpe_Content_Engine\Helper\Sync\Batches; 4 4 5 use ErrorException;6 5 use WP_CLI; 7 6 use WP_Query; … … 14 13 use Wpe_Content_Engine\Helper\Progress_Bar_Info_Trait; 15 14 16 use const AtlasSearch\Index\MANUAL_INDEX;17 15 18 16 class Page extends Multisite_Network_Sync { … … 41 39 42 40 /** 43 * @param WP_Post[] $pages Pages.44 *45 * @throws ErrorException Exception.46 */47 protected function _sync( $pages ) {48 if ( count( $pages ) <= 0 ) {49 return;50 }51 52 foreach ( $pages as $page ) {53 \AtlasSearch\Index\index_post( $page, $page->ID, MANUAL_INDEX );54 $this->tick();55 }56 $this->finish();57 }58 59 /**60 41 * @param mixed $items Items. 61 42 * @param mixed $page Page. -
atlas-search/trunk/helper/sync/batches/post.php
r3075724 r3147520 3 3 namespace Wpe_Content_Engine\Helper\Sync\Batches; 4 4 5 use ErrorException;6 5 use WP_CLI; 7 6 use WP_Query; … … 11 10 use Wpe_Content_Engine\Helper\Multisite_Network_Sync; 12 11 use Wpe_Content_Engine\Helper\Progress_Bar_Info_Trait; 13 14 use const AtlasSearch\Index\MANUAL_INDEX;15 12 16 13 class Post extends Multisite_Network_Sync { … … 36 33 } 37 34 38 /**39 * @param WP_Post[] $posts Posts.40 *41 * @throws ErrorException Exception.42 */43 protected function _sync( $posts ) {44 if ( count( $posts ) <= 0 ) {45 return;46 }47 48 foreach ( $posts as $post ) {49 \AtlasSearch\Index\index_post( $post, $post->ID, MANUAL_INDEX );50 $this->tick();51 52 }53 $this->finish();54 }55 35 56 36 /** -
atlas-search/trunk/helper/sync/graphql/client.php
r3042698 r3147520 100 100 array( 101 101 'headers' => $headers, 102 'timeout' => 20,102 'timeout' => 30, 103 103 'ignore_errors' => true, 104 104 'body' => wp_json_encode( -
atlas-search/trunk/includes/class-wpe-content-engine.php
r3143797 r3147520 225 225 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/index/post.php'; 226 226 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/index/semantic-search.php'; 227 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/index/batch.php'; 227 228 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/hooks/filters.php'; 228 229 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'src/migrations/rename-post-keys-config.php'; -
atlas-search/trunk/includes/smart-search-settings/build/asset-manifest.json
r3143797 r3147520 2 2 "files": { 3 3 "main.css": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css", 4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main. d2b1874d.js",4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.2259e6a0.js", 5 5 "static/media/wpengine-logo.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/wpengine-logo.40f3a1215fbea4708a6a4bff9624fece.svg", 6 6 "static/media/content-copy.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/content-copy.e50f17791e757794684afc63d5d4cb00.svg", … … 18 18 "index.html": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/index.html", 19 19 "main.751d9a0b.css.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css.map", 20 "main. d2b1874d.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.d2b1874d.js.map"20 "main.2259e6a0.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.2259e6a0.js.map" 21 21 }, 22 22 "entrypoints": [ 23 23 "static/css/main.751d9a0b.css", 24 "static/js/main. d2b1874d.js"24 "static/js/main.2259e6a0.js" 25 25 ] 26 26 } -
atlas-search/trunk/includes/smart-search-settings/build/index.html
r3143797 r3147520 1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main. d2b1874d.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css" rel="stylesheet"></head>1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.2259e6a0.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.751d9a0b.css" rel="stylesheet"></head> -
atlas-search/trunk/src/index/post.php
r3143797 r3147520 47 47 GRAPHQL; 48 48 49 const BULK_INDEX_GRAPHQL = <<<'GRAPHQL' 50 mutation BulkIndex($docs: [DocumentInput!], $meta: MetaInput) { 51 bulkIndex(input: { 52 documents: $docs 53 meta: $meta 54 }) { 55 code 56 } 57 } 58 GRAPHQL; 59 49 60 50 61 function format_date( $date ) { … … 64 75 */ 65 76 function index_post( WP_Post $post, int $post_id, string $index_type = AUTOMATIC_INDEX ) { 66 // bring the blocking states. 77 $data = prepare_post( $post, $post_id, $index_type ); 78 79 if ( false === $data ) { 80 return false; 81 } 82 return graphql( INDEX_GRAPHQL, $data ); 83 } 84 85 /** 86 * Indexes a list of WP_Posts 87 * 88 * @param WP_Post[] $posts The posts. 89 * @return mixed 90 */ 91 function bulk_index_posts( $posts ) { 92 $posts_to_index = array(); 93 94 foreach ( $posts as $post ) { 95 $posts_to_index[] = prepare_post( $post, $post->ID, MANUAL_INDEX )['input']; 96 } 97 98 // Index the posts. 99 $variables = array( 100 'docs' => $posts_to_index, 101 'meta' => array( 102 'system' => \AtlasSearch\Meta\get_system_version(), 103 'action' => MANUAL_INDEX . ':bulk-index:' . $post->post_type . ':count=' . count( $posts_to_index ), 104 'source' => \AtlasSearch\Meta\get_domain_name(), 105 ), 106 ); 107 108 return graphql( BULK_INDEX_GRAPHQL, $variables ); 109 } 110 111 /** 112 * Prepare a post for indexing. 113 * 114 * @param WP_Post $post The post. 115 * @param int $post_id The post id. 116 * @param string $index_type The index operation type. 117 * @return array|bool 118 */ 119 function prepare_post( WP_Post $post, int $post_id, string $index_type = AUTOMATIC_INDEX ) { 67 120 if ( false === is_allowed( $post ) ) { 68 121 return false; … … 98 151 $post_array = \AtlasSearch\Hooks\filter_extra_fields( $post_array, $post ); 99 152 100 $variables =array(153 return array( 101 154 'input' => array( 102 155 'id' => \AtlasSearch\Hooks\filter_index_id( $post->post_type, $post_id ), … … 109 162 ), 110 163 ); 111 112 return graphql( INDEX_GRAPHQL, $variables );113 164 } 114 165 -
atlas-search/trunk/src/query/meta.php
r3143797 r3147520 141 141 142 142 if ( 'LIKE' === $compare || 'NOT LIKE' === $compare ) { 143 return '*' . $value . '*'; 143 switch ( str_word_count( $value ) ) { 144 case 1: 145 return '*' . $value . '*'; 146 default: 147 return '"*' . $value . '*"'; 148 } 144 149 } 145 150
Note: See TracChangeset
for help on using the changeset viewer.