right now we store redundant info in as much as we have both the site and the full URL:

          $document->site = $site;
          $document->hash = $hash;
          $document->url = url('node/' . $node->nid, array('absolute' => TRUE));

Perhaps we could replace $document->url with something like $document->drupal_path or $document->relative_url

          $document->relative_url = url('node/' . $node->nid);

In the search results, we can always construct an absolute URL via: $document->site . $document->relative_url, but using the relative URL might be even better ofr the core module in the event the site is accessalbe via different modes (http vs/ https) or w/ different names (either multiple hostnames pointing to the same site, or http://example.com vs. http://www.example.com).

Comments

pwolanin’s picture

This still seems like a useful idea.

blackdog’s picture

This is also needed when using Domain Access, where one node can be present on several domains, but when displayed by solr search always links to the primary domain. I haven't had a look what his meens in code yet, but will eventually as we need it for a client.

blackdog’s picture

Version: 6.x-1.x-dev » 6.x-1.0-alpha6
Status: Active » Needs review
StatusFileSize
new2.14 KB

Here's a starting patch for this. I have added a relative_url field, not deleted the url field.

blackdog’s picture

Title: should we store relative not absolute paths? » Store relative not absolute paths
Version: 6.x-1.0-alpha6 » 6.x-1.x-dev
Category: task » feature
StatusFileSize
new2.86 KB

Updated patch against dev. Still thinks this is important.

blackdog’s picture

Would be nice to get some more input on this.

JacobSingh’s picture

Status: Needs review » Reviewed & tested by the community

I think this is a worthy add.

pwolanin’s picture

Status: Reviewed & tested by the community » Needs work

If we want to do this, I think we should possibly just use 'node/'.$nid rather than url() so that we can pass the result through url() and not have to worry whether a change to the url alias is out of date. In that case, however, it almost seems like we don't need this at all since we are already retrieving the nid? Or is this useful precisely becasue it does capture the alias?

blackdog’s picture

I can't really think of a use for storing other than the nid and using url() for output. A quick test seems to work just fine for me using Domain Access.

Should we remove the url field completely, or just change how the output is done? If we don't use the url field at all, it's redundant info in the index, no?

pwolanin’s picture

url will be highly necessary for multi-site search. Per discussion with Jacob, it's worth indexing the Drupal path/relative url especially if we imagine we might have search results that are mixed (i.e. users and nodes and files).

blackdog’s picture

Of course, you're right.

So how would we decide which output to use?
Would standard be just url(node/nid), but editable through a setting?

pwolanin’s picture

Well, I imagine we'd normally use the Drupal path now until we get multi-site working.

We could change this in apachesolr_search from:

            $results[] = array(
              'link' => $doc->url,

to:

            $results[] = array(
              'link' => url($doc->path),

or some such.

blackdog’s picture

Status: Needs work » Needs review
StatusFileSize
new1.23 KB

Since we allready index path, do we really need the relative url to?

Small patch attached to change output to url($doc->path).

blackdog’s picture

StatusFileSize
new845 bytes

Realised that path isn't always set. New patch uses $doc->nid.

pwolanin’s picture

StatusFileSize
new3.54 KB

Here's a more complete patch.

blackdog’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

pwolanin’s picture

Status: Reviewed & tested by the community » Fixed

committed to 6.x

Status: Fixed » Closed (fixed)

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