#899480: Limit search to same content type changed a bunch of Solr options that should be tested by someone using Solr...

CommentFileSizeAuthor
#3 1130596-uniqueness-solr-nids.patch783 bytesdandaman

Comments

dandaman’s picture

Seems to work pretty well, except for the URLs. The array of results seems to be returned with generic numeric arrays while this code seems to think that the results should be keyed by nid. Thus, this is line 321 of uniqueness.module:

    foreach ($related_content as $nid => $item) {
      // Build items and avoid duplicates.
      if (!in_array($nid, array_keys($items))) {
        $items[$nid] = $item;
        $items[$nid]['href'] = url('node/' . $nid);
      }
      if (++$i > $limit) {
        // At least one more than the results_max limit were found
        // -> communicate "and more" to the widget 
        $items[$nid]['more'] = TRUE;
        break;// LOOP EXIT
      }
    }

The URLs on my results were "node/0", "node/1", "node/2", "node/3" and so on.

dandaman’s picture

Actually, looks like they are keyed correctly with the nid at some point, but the array_merge() function wipes them out here (line 439 of uniqueness.module):

  if ($values['title']) {
    $title_content = uniqueness_solr($values['title'], $filter, $nid);
    if (!empty($title_content)) {
      $related_content = array_merge($related_content, $title_content);
    }
  }
  // Search tags.
  if ($values['tags']) {
    $tags = explode(',', $values['tags']);
    foreach ($tags as $tag) {
      $results = uniqueness_solr(trim($tag), $filter, $nid);
      if (!empty($results)) {
        $related_content = array_merge($related_content, $results);
      }
    }
  }

Maybe we should use the "+" operator instead of "array_merge()" in both of these cases?

dandaman’s picture

StatusFileSize
new783 bytes

Yeah, that worked for me. Here's a patch:

bforchhammer’s picture

Status: Active » Fixed

Thanks for testing. Patch looks fine, commited.

Status: Fixed » Closed (fixed)

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