Skip to content

Allow sorting by element name

Erwan Rouchet requested to merge search-sort into master

Closes #1375 (closed)

Sorting by element_text was already possible, but since the field was tokenized to allow searching on each word separately, the sorting was yielding incomprehensible results.

I tried to use a CopyField, one of the options offered in the sort documentation, to store the full, unmodified element name alongside the tokenized version. create_copy_field exists, but handling updates to those later on would be much more complex than with regular fields. I used a SortableTextField instead, which handles this storage by itself.

This will require a manage.py reindex --drop to avoid a HTTP 400 by Solr because updating from TextField to SortableTextField does not seem to be possible.

I was slowed down by various issues on the frontend search form, the API client, the API view and the indexer, and will create various follow-up issues later.

@babadie Is #782 (closed) still useful? It could be implemented more quickly now, but it isn't requested anymore.

Merge request reports

Loading