Comments

drewish’s picture

On one site I've got it got totally stalled. It's calling search_api_index_items() which returns 0 meaning it's not doing anything but because the remaining stuff keeps showing up it keeps trying. I'm guessing they're all stuck in the queue some place. I guess I need to figure out how to clear the queue so it starts over.

Meant to post this over on #1262478: Make "Index now" consume the items in the cron queue first

Yaron Tal’s picture

StatusFileSize
new2.34 KB

I attached a patch (for the 7.x-1.0 release) to temporarily work around the current limitations. Instead of trying to process all nodes and then index them all, the module will now process and index as much nodes as are set to be in a batch (configurable on the settings tab), and send those to the index before starting with the next batch.

In our configuration we have a couple of big nodes, which would make the module crash somewhere in the middle. By patching it like this we can just run it a couple of times with small batches, and when it runs out of memory we at least have all the nodes till that point in the solr index. Real batch support would be better, but I don't have enough time to create that, and this works as a temporary workaround.

I know this won't make it in to core, but it might help some people.

farald’s picture

Second that. We need a batch operation here. Indexing 5000 nodes, 200 at a time is time consuming. :)

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new4.24 KB

It's a big day for the Search API … Finally, the longest-lasting feature request is set to "needs review"!

Please help me by testing (and review) the attached patch to finally fix this problem!

Status: Needs review » Needs work

The last submitted patch, 1225620--batch_api_for_index_now-4.patch, failed testing.

orakili’s picture

Status: Needs work » Needs review
StatusFileSize
new4.63 KB

Tested patch #4. The calculation of the limit is done after the batch is set up so it's not used.

Adding a modified version of the patch.

Status: Needs review » Needs work

The last submitted patch, 1225620--batch_api_for_index_now-5.patch, failed testing.

orakili’s picture

Status: Needs work » Needs review
StatusFileSize
new10.75 KB

Similar patch as in #6 + batch indexing via drush.

I've modified a bit the behaviour of the drush function "search-api-index". The limit parameter corresponds now to the number of batch runs and not the number of items to index.

I've tested it to index 400,000+ nodes.

The last submitted patch, 1225620--batch_api_for_index_now-6.patch, failed testing.

drunken monkey’s picture

StatusFileSize
new13.31 KB

Thanks for the help, orakili!

I have an improved version here (sadly, developed independently of you, as I didn't think to check back here after starting this on Wednesday), which should work completely and also has test cases which are modified accordingly.
One important addition is also that items, which couldn't be indexed, are now freshly marked as “changed”, so we won't try to index them again right in the next batch. (In the worst case, those could accumulate and make any indexing impossible.)

I've also added your Drush modifications. I can't test them here (Drush doesn't work for me), so it would be great if someone else could review them! Also, why do you need your own batch processing function and can't use the "normal" one? I understand the "finished" callback, as it has to use drush_log() instead of drupal_set_message(), but the other one shouldn't be different, right? (We could also consider using a variable to determine what output function to use, to also unify the two "finished" callbacks – but I guess we should better refrain from such magic.)

Please also review my newest patch regarding the normal UI!

orakili’s picture

Arf, I've just finished to modify the patch in #8 and adapt the test to handle the use of the batch API.

I used a different callback for drush just because of the "format_plural" function which can not (should not) be used with drush as it calls t().

Just attaching the patch to make sure we don't lose it.

Well I will review yours and combine the best parts and try to unify the callback and finished functions.

orakili’s picture

Also maybe it could be interesting to have 2 fields under the "index now" section with the number of batches and the number of items per batch. It would be flexible. Same for the drush function. What do you think?

orakili’s picture

StatusFileSize
new18.61 KB

Hi,

Here is the patch merging both #10 and #11 with some modifications.

Mostly it contains:

  • Items that couldn't be indexed are freshly marked as changed (see #10).
  • Common batch creation, callback and finished functions for both the admin UI and drush. They have been moved to search_api.module.
  • Changed the admin UI to provide 2 fields to control how many items are indexed: number of items to index (limit) and number of items per batch run (batch_size).
  • Added a batch_size parameter to the search-api-index drush function to have a behavior similar to the UI.

I've tested both the UI and the drush function with 10,000+ items.

randallknutson’s picture

Status: Needs review » Reviewed & tested by the community

Patch #13 worked for me. Thanks for saving me tons of work!

Ace Cooper’s picture

Love patch #13, thank you orakili!

Anonymous’s picture

I have also tested the patch from #13 with custom entities and a custom datasource.inc
It works fine.

drunken monkey’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new18.86 KB

The previous version displayed a wrong error message when the entered limit was greater than the remaining items. This is fixed in the attached patch.
I also by default hid the settings of the „Index now“ form, as I guess the defaults are what users will usually want. Does this make sense to you, too?

Thanks for testing, everyone! Please also try out this newest patch, and than we can hopefully finally fix this!

Anonymous’s picture

Works fine!

orakili’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #17 works fine. Flagging as RTBC.

jsacksick’s picture

Is there any particular reason for this to stay in RTBC ? :p

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks for reviewing!

joelrosen’s picture

Any idea when we might expect to see this feature brought into the stable branch? I have a client who's asking for it but I'm hesitant to switch over to the dev branch. Thanks!

Status: Fixed » Closed (fixed)

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