Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Indexing (for 4.0) #2585

Merged
merged 7 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add an option to use static bulk (the opposite of dynamic bulk)
  • Loading branch information
felipeelia committed Mar 4, 2022
commit 78298d10b8193ebbfeadaee6479cc14007faec47
4 changes: 4 additions & 0 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@ public function delete_transient_on_int( $signal_no ) {
* [--nobulk]
* : Disable bulk indexing
*
* [--static-bulk]
* : Do not use dynamic bulk requests, i.e., send only one request per batch of documents.
*
* [--show-errors]
* : Show all errors
*
Expand Down Expand Up @@ -748,6 +751,7 @@ public function index( $args, $assoc_args ) {
'network_wide' => ( ! empty( $assoc_args['network-wide'] ) ) ? $assoc_args['network-wide'] : null,
'nobulk' => $no_bulk,
'offset' => ( ! empty( $assoc_args['offset'] ) ) ? absint( $assoc_args['offset'] ) : 0,
'static_bulk' => ( ! empty( $assoc_args['static-bulk'] ) ) ? $assoc_args['static-bulk'] : null,
];

if ( isset( $assoc_args['show-errors'] ) || ( isset( $assoc_args['show-bulk-errors'] ) && ! $no_bulk ) || ( isset( $assoc_args['show-nobulk-errors'] ) && $no_bulk ) ) {
Expand Down
6 changes: 5 additions & 1 deletion includes/classes/IndexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,11 @@ protected function index_next_batch() {
$should_retry = true;
}
} else {
$bulk_requests = $indexable->bulk_index_dynamically( $queued_items_ids );
if ( ! empty( $this->args['static_bulk'] ) ) {
$bulk_requests = [ $indexable->bulk_index( $queued_items_ids ) ];
} else {
$bulk_requests = $indexable->bulk_index_dynamically( $queued_items_ids );
}

$failed_objects = [];
foreach ( $bulk_requests as $return ) {
Expand Down