Active
Project:
Apachesolr Sort
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 Nov 2012 at 06:27 UTC
Updated:
11 Jan 2019 at 05:55 UTC
Jump to comment: Most recent
Comments
Comment #1
libbyy commentedComment #2
sawtell commentedYou can add a sort in hook_apachesolr_query_prepare().
You can find the list of fields in the solr index at http://example.com/admin/reports/apachesolr/SERVER_NAME
The field you want to add as a sort needs to be single valued, multivalued fields cannot be used to sort results.
Comment #3
Yorgg commentedI can't seem to create a single valued "ds_" field using date module.
It's being stored as a multivalued field even if I don't tick the "collect end date" or change the number of values to multiple. The workaround was to use published date to perform the sort.
How can I make this the default sort? I don't want to expose the sort block.
Comment #4
ressaThanks for the tips @ls206. I wanted to sort by a Price field, and had to use 'its_field_price' for it to work. There was also a 'itm_field_price' which didn't work.
I really think your explanation on how to add a custom sort field should be added to the README.txt file.
Comment #5
subhojit777@j_nunes The point is apache solr module considers custom field as multivalued, nevertheless the field is single valued. You can see
apachesolr_get_field_mappings($entity_type)inapachesolr.module. What you can do is alter field mapping for the custom field. See the code:This way you can alter the cardinality of a solr field.
Comment #6
sarikak commentedHow to name the fields to be used in sorting.As @ressa mentioned in above comment I am confused in naming the fields.
Also while using a custom fields date and year for sorting, I am getting results in wrong sort order.
Any help will be appreciated.Thanks