I'm working on a site with 78k nodes, only 24k of which end up in the search index (aka have the right bundle, are published). It's a bit of a pain to watch 78k node_loads happen, only a third of which are really necessary.

After poking around, I realized that the

search_api_item

table is initially populated with every node on the site, and that search_api uses this as a list of documents to index. Therefore it's a simple matter to truncate the table, and re-populate it with a subset of all nodes I'm currently interested in indexing, whether it's just 2 (while hacking on indexing code), a comprehensive subset (for thorough QA), or all nodes that should be in the index (24k).

I made a Makefile (https://gist.github.com/dergachev/9650039) that provides the following targets:

make populate-several              
#    populates {search_api_item} with 2 nodes; useful for development

make populate-pruned
#    populates {search_api_item} with 5k nodes; useful for QA

make populate-active
#    populates {search_api_item} with 24k nodes, for speedup

make reset-php
#    populates {search_api_item} with 78k nodes; restores table to original state

make index
#    runs 'drush sapi-i'; requires 'apt-get install pv'

make commit
#    asks the solr server to immediately commit pending changes (no 2 minute delay)

The Makefile is project specific (it hardcodes bundle names and nids, and might cause trouble if you have multiple indexes) but might be useful to anyone working with search_api. Ideally someone would port it to a drush command, but in the meantime I'm posting it here.

Comments

dergachev’s picture

Issue summary: View changes
drunken monkey’s picture

Status: Active » Closed (duplicate)

Thanks for posting this here, might really be useful for some others!
I don't think we will include this in the module, though, since it's a bit too hacky as a solution. See #1184610: Limit indexes to specific entity bundles for a much cleaner approach.