Custom sorting in simple search results screens

Hi there;

I’d like to implement the same sort of sorting options users get when they do an advanced search for simple search, such as allowing users to sort by date, title, creator, etc. I’ve been reading forum posts on this, and the impression I’m getting is that it’s not possible because of the way simple search operates. For example, there’s this post on a similar topic:

Is there any way to offer users to option to sort simple search results?

We have accomplished this by writing a plugin that uses its own DispatchFilter to intercept requests for search (simple search) and items/browse (advanced search). It then redirects to the plugin’s own “Find” page for either kind of search request.

The Find page hooks into items_browse_sql to intercept both simple search and advanced search queries. It rewrites the Omeka generated SQL so that it selects from the search_texts table (used by simple search) joined with the element_texts table (used by advanced search). The plugin uses its own views to display the hybrid results and to provide the ability to sort on any element. In other words, the plugin performs simple and advanced search queries using the same code, and it displays all search results using the same code.

In contrast, the core Omeka logic uses two different code paths to execute the two kinds of searches and it uses two different code paths to display the two kinds of results. The simple search path can’t sort by element (e.g. date, subject, creator) because it only operates on the the search_texts table’s ‘text’ column which contains the text of all elements. As such, there’s no way to write a SQL query to sort search_texts records based on a single element e.g. creator. Because our solution joins search_texts and element_texts, it can use ORDER BY to sort on element_texts even though the query found the simple search keywords in search_texts.

Hopefully we’ll be able to share our plugin in the future, but at the moment it has dependencies on the larger solution and is not able to operate standalone. However, I hope this quick overview explains why your very reasonable request is not so simple to implement.

sigh That’s what I thought. Thanks.