For some reasons, when you have more than 1 index and you run drush sapi-i without arguments, this will fail once the first one is finished.
For the second one, it doesn't even enter the batch callback (_search_api_batch_indexing_callback).

Comments

jackbravo’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.58 KB

There is a bug drush_search_api_index function. When having two indexes, the limit for the second index is the same as the limit for the first index. So you can have 34 items to index on the first one and none on the first, but it will try to index also 34 items on the second index.

Also, and I think this is related to #1823910: Drush sapi-i: "Couldn't create a batch, please check the batch_size and limit parameters.", the module tries to create a batch process even when there are no items to process, which results in an error.

Here is a patch that defines a $index_limit variable that gets set for every index, instead of relying on the $limit variable which doesn't work when running for multiple indexes.

fago’s picture

Issue summary: View changes
Status: Needs review » Needs work

Thanks. The patch fixes the number of items that should be index, however search api still hangs when it tries to start indexing the second index for me; i.e. it does not start indexing the second index.

cyberwolf’s picture

I reworked the patch quite a bit:

  1. I split off handling one index to a separate function, which ensures you can not mix up $remaining/$limit/$batch_size of several indexes
  2. Start processing the full batch at the end, if any of the indexes added a batch set
cyberwolf’s picture

Status: Needs work » Needs review
Anonymous’s picture

thanks! patch #3 works for me with 4 indexes enabled.

isolate’s picture

Status: Needs review » Reviewed & tested by the community

Patch #3 works!

drunken monkey’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Thanks a lot for reworking the patch! It looks great, and if others say it works, too, then even better. ;)
Committed.
Thanks again!

I just fixed a few comments before committing, one issue I had was this:

+++ b/search_api.drush.inc
@@ -297,46 +297,71 @@ function drush_search_api_index($index_id = NULL, $limit = NULL, $batch_size = N
+ * @return boolean

In type hinting in doc blocks, you should use bool, not boolean (see here).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.