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
Comment #1
pwolanin commentedThis still seems like a useful idea.
Comment #2
blackdog commentedThis 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.
Comment #3
blackdog commentedHere's a starting patch for this. I have added a relative_url field, not deleted the url field.
Comment #4
blackdog commentedUpdated patch against dev. Still thinks this is important.
Comment #5
blackdog commentedWould be nice to get some more input on this.
Comment #6
JacobSingh commentedI think this is a worthy add.
Comment #7
pwolanin commentedIf 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?
Comment #8
blackdog commentedI 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?
Comment #9
pwolanin commentedurl 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).
Comment #10
blackdog commentedOf 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?
Comment #11
pwolanin commentedWell, I imagine we'd normally use the Drupal path now until we get multi-site working.
We could change this in apachesolr_search from:
to:
or some such.
Comment #12
blackdog commentedSince we allready index path, do we really need the relative url to?
Small patch attached to change output to url($doc->path).
Comment #13
blackdog commentedRealised that path isn't always set. New patch uses $doc->nid.
Comment #14
pwolanin commentedHere's a more complete patch.
Comment #15
blackdog commentedLooks good!
Comment #16
pwolanin commentedcommitted to 6.x