sarnia GIT latest
search_api 7.x-1.8
search_api_solr 7.x-1.2

I got
Notice: Undefined index: search_api_id in SearchApiSolrService->extractResults() (line 1033 of /modules/contrib/search_api_solr/includes/service.inc).
when I try to access URL sarnia/sarnia_entity_type/%id.

I fixed it by modifying line 69 in sarnia/service.inc file.

    $ret = array_merge($ret, array(
      // local property name => solr doc property name
      'search_api_id' => $sarnia_entity_info['id_field'],//'is_search_api_id', <<here
      'search_api_relevance' => 'score',
      'search_api_item_id' => $sarnia_entity_info['id_field'],
      'search_api_random' => 'random_' . rand(1, 200),
    ));
CommentFileSizeAuthor
#2 id_field_fix.patch520 bytesjmdeleon
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jmdeleon’s picture

Patch worked for me. Configuration:

These two patches should be rolled in. Sarnia has been instrumental for Drupal Solr development I have been doing.

jmdeleon’s picture

Issue summary: View changes
FileSize
520 bytes

Created a patch file for this specific fix some time back, against dev version. Putting it up here now.

dcam’s picture

Status: Active » Reviewed & tested by the community

#2 solved a different problem that I experienced.

I followed the example instructions in the documentation of setting up an index using the apachesolr module. I also applied some other patches that are here in Sarnia's issue queue. Anyway, Solr returns results where the original node path is contained in the id field. Of course, I'm using the entity_id field as the unique integer ID for use with Sarnia, but results seem to be cached by the Search API according to that other id field. Without #2, Sarnia doesn't replace the bad, non-integer id with the integer ID that you choose, which is probably the original cause of this issue.

Anyway, when I wanted to see the Sarnia entity displayed at the sarnia/{$entity->type}/{$entity->id} path, I got a 404 when trying to access it with the entity_id. That's because the id field from Solr was being used as the $entity->id, resulting in an $entity->id that looked something like *****/node/nid. #2 fixes the problem by replacing whatever id the Search API uses to cache the result with the field you select.

dcam’s picture

#2 also fixed an issue where I got an error when trying to "Link this field to its entity" in Views. That makes sense because the path was all wrong like I mentioned in #3.

dcam’s picture

Status: Reviewed & tested by the community » Fixed

This was committed to 7.x-1.x-dev.

Commit: http://drupalcode.org/project/sarnia.git/commit/d3f6a99

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.