I need your advise. I have this code:

$nid = 5; //example
$engine = 'mustang';
$node = new stdClass();
$node->nid = $nid;          // node id
$node->type = 'car';  // aka content type
$node->engine[LANGUAGE_NONE][0]['value'] = $engine;
field_attach_update('node', $node);
//send to solr
apachesolr_mark_entity('node', $nid);

The code was used to update a field called engine in content type car without using node_save(). This way is used because more lightweight then calling using node_load() and then node_save().

But unfortunately I can not send the entity to solr using apachesolr_mark_entity(). apachesolr_mark_entity() needs node_save() to work.

How to allow apachesolr_mark_entity() works although I don't use node_save()?


apachesolr_mark_entity() needs node_save() to work.

I would have to disagree; this is the code:

function apachesolr_mark_entity($entity_type, $entity_id) {
  module_load_include('inc', 'apachesolr', 'apachesolr.index');
  $table = apachesolr_get_indexer_table($entity_type);
  if (!empty($table)) {
      ->condition('entity_id', $entity_id)
      ->fields(array('changed' => REQUEST_TIME))

As you can see it's just a simple database update, node_save() is not involved.

  • yes I've also checked the function, but it's not been triggered with field_attach_update(). I've also checked in table apachesolr_index_entities_node (the condition is empty) there's no new data inserted. – Fatimah Wulandari Oct 31 '14 at 2:27
  • so, when the node is never been sent to table apachesolr_index_entities_node, or let's assume the table is empty, node_save() will create new record to the table. what could possible make field_attach_update() works as node_save(). do I miss something in object $node ? – Fatimah Wulandari Oct 31 '14 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.