Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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),
));
Comment | File | Size | Author |
---|---|---|---|
#2 | id_field_fix.patch | 520 bytes | jmdeleon |
Comments
Comment #1
jmdeleon CreditAttribution: jmdeleon commentedPatch worked for me. Configuration:
These two patches should be rolled in. Sarnia has been instrumental for Drupal Solr development I have been doing.
Comment #2
jmdeleon CreditAttribution: jmdeleon commentedCreated a patch file for this specific fix some time back, against dev version. Putting it up here now.
Comment #3
dcam CreditAttribution: dcam commented#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.
Comment #4
dcam CreditAttribution: dcam commented#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.
Comment #5
dcam CreditAttribution: dcam commentedThis was committed to 7.x-1.x-dev.
Commit: http://drupalcode.org/project/sarnia.git/commit/d3f6a99