Heads up! This content is more than six months old. Take some time to verify everything still works as expected.
I had the occasion to need to change the search indexing logic for a specific content type. The site has thousands of nodes, many not of the type that had its search index logic altered. Calling for a full search reindex would be a very time-consuming process, when I only need to do a fourth of them. The answer turns out to be extremely simple.
With a bit of fancy sql, you can simply target any set of existing
nodes for update. All you have to do is set update a single table:
search_dataset. Normally whenever a node is saved, or a comment
is added, code is fired to 'touch' that table, setting the reindex
column equal to a unix timestamp for the time of the request. Then
search churns over anything with a timestamp greater than 0
So for our need? Easy sql:
UPDATE search_dataset SET reindex = UNIX_TIMESTAMP(NOW()) WHERE `type` = 'node' AND sid IN ( SELECT nid FROM node node WHERE -- conditions )
drush search-index command!