Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
/**
* Handles aliases for field to make nicer URLs.
*
* @param $field_map
* An array keyed with aliases with the real Solr index field name as value.
*
* @return DrupalSolrQueryInterface
* The called object.
*/
function addFieldAliases($field_map);
According to apachesolr.interfaces.inc
, a call to DrupalSolrQueryInterface::addFieldAliases
could look like:
$query->addFieldAliases(array('myalias' => 'real_solr_field_name'));
but the code in SolrBaseQuery::getSolrsortUrlQuery() expects the field map to be in the opposite order.
Comment | File | Size | Author |
---|---|---|---|
#6 | 1861544-addFieldAlias-6.patch | 1.2 KB | Nick_vh |
#4 | 1861544-addFieldAlias-1.patch | 531 bytes | fizk |
#1 | 1861544-field-map-getSolrsortUrlQuery-1.patch | 774 bytes | fizk |
Comments
Comment #1
fizk CreditAttribution: fizk commentedHere's a patch.
Comment #2
fizk CreditAttribution: fizk commentedComment #3
Nick_vhI'm not sure if this is actually a smart move to do an array flip.
I'd have to look deeper in this, could you also make some simpletest proving that the current behaviour is wrong? Maybe updating the documentation is better and we don't suddenly break assumptions?
Comment #4
fizk CreditAttribution: fizk commentedWell, we'll be breaking assumptions either way - some think the documentation is right, and others know it isn't.
I agree, changing the documentation is probably going to affect less people. Here's a patch.
Comment #5
fizk CreditAttribution: fizk commentedComment #6
Nick_vhAdding some more docs, I'm planning to update the whol einterface in #1897556: Update documentation for all the functions and make sure it reflects reality so this already helps. Could you actually clarify for me for what you are trying to implement this and it breaks?
Committed to 7.x1.x, thanks!
Comment #7
Nick_vhComment #8
fizk CreditAttribution: fizk commentedI'm implementing
hook_apachesolr_query_prepare()
and callingaddFieldAliases()
so I can sort by field names that are prettier than the default field names.For anyone else reading this, please note the order should be the other way around (eg.
$query->addFieldAliases(array('ds_created' => 'date'));
is correct).Comment #9
Nick_vhSo the drawback of this code working this way is that you can only have 1 alias per field?
Comment #10
pwolanin CreditAttribution: pwolanin commented