I am working on a project where I had to add a few sortable fields. In my design however, I needed to be able to change the title of the sortable fields. I implemented hook_luceneapi_sortable_fields_alter() and saw all of my sortable fields. However, the "Relevancy" field was not in the $fields array, and I wanted to be able to change the title of that link.

I could probably take care of this in the theme layer, but it doesn't make a lot of sense to alter most of the fields in one place and the Relevancy field somewhere else.

Even though Relevancy is not a true field and is more of a reset flag, could you please add this to the $fields array?

CommentFileSizeAuthor
#2 luceneapi-666102-2.patch4.72 KBcpliakas

Comments

cpliakas’s picture

Issue tags: +6.x-2.0

Hi ebeyrent.

I think this is a reasonable request. It is a little more challenging than it seems since the array keys in this hook are Lucene fields, and relevancy has no field as you mentioned above. Furthermore, relevancy should really only be sorted in one direction. It also serves as a way to clear all other sorts. With that being said, you are correct in that it should be able to be altered by hook_luceneapi_sortable_fields_alter().

Since it is not a Lucene field, I am not sure what to put as the array key. Maybe 0? The word "relevancy" shouldn't be used because technically it could be the name of a field. I could also use "score" since Lucene fields should not be named either "id" or "score" (see section 46.10.1 in http://framework.zend.com/manual/en/zend.search.lucene.best-practice.html). I'm kind of up in the air about this, and anyone is free to weight in.

Flagging for the 2.0 stable release, which is the next expected release.

Thanks for the bug report,
Chris

cpliakas’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new4.72 KB

After talking with ebeyrent, using "score" as the field seems to be the way to go. If it were anything else it would either be confusing (i.e 0 matching relevancy) or would open the door for field name conflicts. The attached patch is a workaround to this issue.

Note that the patch was made against the RC2 version of Search Lucene API.

cpliakas’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in commit #305742.

Status: Fixed » Closed (fixed)
Issue tags: -6.x-2.0

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