search_api_solr with accurate radioactivity sorting in views We're using Views to display our search_api_solr results. We'd like to be able to show these results by radioactivity (popularity) sort order.

The radioactivity field is one of several fields indexed by Solr so that it can be used by the Solr views for sorting.

The problem is, the radioactivity value that gets indexed by solr only gets updated when the entity gets indexed. The entity only gets indexed when it gets changed (node_update), or when the Solr index is cleared and everything is reindexed again. Having an entities radioactivity energy adjusted by visiting the entity, does not trigger solr to reindex the entity - and probably rightly so.

I've tried adding a relationship in the Search View to node, but that isn't available as a "search index" view type.

Does anyone have any other suggestions for solving this? There doesn't seem to be a radioactivity hook that lets you execute your own code, i.e. update search_api_item table to say its changed.
As you say there's no API, so you're probably going to have to resort to patching the module.

There are at least two places you'll need to make additions as far as I can tell:


_radioactivity_update_energy()
radioactivity_cron()


I would suggest adding your own hook which gets fired whenever an entity is updated in either of those functions, and perform the search indexing there.

You should have a good think about the values you use for half lives/Solr processing delays if you choose to implement it like this. If your values for those settings aren't sensible you could end making the changes without actually seeing any effect. Also, depending on the amount of traffic the site receives, you could slow your server down quite a bit doing this.