How to update table taxonomy_index when adding a node referencing a term?
I ended up figuring this out. here is what I did:

$result=db_query("SELECT nid FROM node WHERE type = 'lesson'");
foreach($result as $row){
    $node=entity_load('node', $row-&gt;nid);
    $result =  taxonomy_build_node_index($node);
}


This ensures that my lesson node is tracked in the taxonomy_index table. I should probably start learning the class-based approach, but for now this works.