Hi !

First of all thanks for this great module, it's saving me a considerable amount of time.
I'm writing this note because I stumbled upon a tiny issue when indexing my content : the additional parameters are not taken into account when gathering the URL to index.

E.g. : if my content has a link field with : http://www.mywebsite.com/index.php?param1=test&param2=test, the module will try and index the page http://www.mywebsite.com/index.php only.

I don't know if it's an actual issue or if I'm just misusing the module but I had to tweak it a little bit to make it work.

On line 119, formerly :

for ($i = 0; $i < count($values); $i++) {
          $fields[] = array(
            'key' => $index_key,
            'value' => apachesolr_link_fetch_url_contents($values[$i]['url']),
          );
        }

Now :

for ($i = 0; $i < count($values); $i++) {
		  if(!empty($values[$i]['query'])) {
            $fields[] = array(
              'key' => $index_key,
              'value' => apachesolr_link_fetch_url_contents(url($values[$i]['url'], array('query' => $values[$i]['query']))),
            );		  
		  } else {
		    $fields[] = array(
              'key' => $index_key,
              'value' => apachesolr_link_fetch_url_contents($values[$i]['url']),
            );
		  }
        }

I just added the query component and built the URL using Drupal's url() function and now it's working great !

Please tell me if you want me to commit a patch or anything.

Regards

Comments

bc’s picture

I don't use apachesolr_link, rather, I am working with a 6.x site, but I do output the link field in search results. I came across this issue during my reserach and figured I'd share my notes here just in case :)

This bug is related to a suite of Link module issues:

#1728098: URL query string output trouble
#1309658: Fragment and query string disappear from views tokens
#1645640: Since <front> isn't implemented, take it off the project page until it is.
#1397978: Link field custom formatter Query String cut off from url

Most of the bugfixes are for 7.x.

To overcome this problem in apachesolr-6.x-2.x if you're *not* using this apachesolr_link module and instead simply including links as custom solr fields, you can do this:

function MODULE_apachesolr_index_document_build_node($document, $node, $env_id) {
  // ...
    if ($node->field_news_uri[0]['url']) {
    $url = $node->field_LINK_FIELD_NAME[0]['url'];
    if ($node->field_LINK_FIELD_NAME[0]['query']) {
      $url .= '?' . $node->field_LINK_FIELD_NAME[0]['query'];
    }
    $document->setField('sm_SOLR_LINK_FIELD_NAME', $url);
  }
  // ...
}
bc’s picture

Also, another piece of the problem is with module weights - I was able to fix many solr/link related bugs by increasing apachesolr's weight in the system table.

bc’s picture

Issue summary: View changes

EDIT : Corrected the code to test the query array