Currently 'bundle' is not a required field in schema.xml. However the apachesolr module does sometimes assume that a bundle is always available. Even though the apachesolr module makes sure that a bundle is always added, this isn't always the case - for example when content gets added to Solr by Nutch.

One such occurrence is in the apachesolr_search.module:
$snippet = theme('apachesolr_search_snippets__' . $doc->entity_type . '__' . $doc->bundle, array('doc' => $doc, 'snippets' => $snippets));

Because the schema.xml might still change, I'm just reporting this as something that we might want to take into consideration in future discussion.

CommentFileSizeAuthor
#3 1279164-3.patch7.7 KBpwolanin

Comments

pwolanin’s picture

Ah, good point.

Perhaps we should make it like this?

$hook = 'apachesolr_search_snippets__' . $doc->entity_type;
if (!empty($doc->bundle)) {
  $hook .= '__' . $doc->bundle;
}
snippet = theme($hook, array('doc' => $doc, 'snippets' => $snippets));
wmostrey’s picture

That would be a good start yes. I found some interesting things when crawling a non-Drupal site using Nutch. Only having the bare minimum fields (I believe they're id, entity_id, entity_type, label, content, site, url (and hash for apachesolr_multisitesearch)) throws a couple of notices. The Apache Solr module provides more fields to Solr, and it expects them to be there as well. Bundle is one such example, path is another.

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new7.7 KB

Per other discussion (IRC?) this patch makes entity_id optional in the schema, and tries to avoid notices by setting to NULL any missing field listed in the 'fl' param.

wmostrey’s picture

These are great additions, and things work as expected. As far as I'm concerned this is good to go, unless you want to wait for one extra review.

pwolanin’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

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