When an associated node gets changed, the original node doesn’t reflect the changes on solr. In this case the node which contains such information on solr should be pushed/marked for indexing. It is considered that search_api is being used. The current example will work when node gets pushed immediate to solr when changes are made.
Right now i7san.net is taken to show the example.
Here the site has Club group which is a node. This group is used in projects. So whenever s project is created, the Group on solr should show the total number of projects. Also when a donation is made to a project, the corresponding club/group gets sum to donation made to this.
In this case, whenever such case occurs, we only need to make an entry in search_api_item.
mysql> desc search_api_item;
| Field | Type | Null | Key | Default | Extra |
| item_id | int(10) unsigned | NO | PRI | NULL | |
| index_id | int(10) unsigned | NO | PRI | NULL | |
| changed | bigint(20) | NO | | 1 | |
3 rows in set (0.00 sec)
As we can see, search_api_item has following parts :
item_id – the nid of the node or uid of the user
index_id – the index id in which the node should go
changed – 0 stands already indexed, 1 means it need to be indexed and -1 means never indexed.
So in this table make an entry for the club which needs to be pushed.
replace into search_api_item (item_id, index_id, changed) values (100, 10, 1);
Here 100 = club nid
10 = index_id for club
1 = marked for indexing