search_cop
search_cop copied to clipboard
Suggestion: Add support for sort in the free text search
It would be super nice if the free expression search would support sorting, so we can do:
User.search "status = active and comments > 1 sort : -joined_on"
or some other human-friendly syntax. Here I assumed -
for descending order, and +
(or no prefix) for ascending order.
Is this considered out of scope for search_cop? I just find myself beginning to enjoy just giving the users a single search field, but now I still have to provide them with "Sort By" UI controls, which I would love to retire as well.
Hi, sorry, but i'd consider this to be out of scope and I don't see a strong use case for it, as i don't think anyone will ever remember the syntax for it and a simple select box usually is sufficient. Moreover, i think it can overcomplicate things and i don't know any searchengines (like elasticsearch or so) which have something like that
Well - that is of course your call, but it does exist, closer than you think 😄 ... https://github.com/mrkamel/search_cop/issues?q=is%3Aissue+is%3Aopen+sort%3Acreated-asc
This is the concept of "everything is an expression" - Github still has UI controls to assist, but they just autofill the search expression.
interesting. thx for pointing this out.
By the way, I found another glorious page on GitHub that demonstrates the use of this very nicely. This is what I would like to implement with search cop in my systems.
See this: https://github.com/pulls?q=is%3Aclosed+is%3Apr+author%3ADannyBen
Notice that:
- The entire expression is in the URL
- The buttons on top change the expression
- The sorting and other options on the right also change the expression.
From development standpoint, Github team just implemented a very smart expression mechanism, which provides advantages to all stakeholders:
- The developers are not asked every day to "add another search feature / field"
- The UI guys can create buttons and select boxes to inject phrases to the expression
- The average user has a nice UI
- The advanced user has a smart expression box.
As far as I know, SearchCop is the closest gem to being able to enable such a dreamy functionality.