search_cop icon indicating copy to clipboard operation
search_cop copied to clipboard

Suggestion: Add support for sort in the free text search

Open DannyBen opened this issue 4 years ago • 4 comments

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.

DannyBen avatar May 18 '20 11:05 DannyBen

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

mrkamel avatar May 18 '20 14:05 mrkamel

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

image

This is the concept of "everything is an expression" - Github still has UI controls to assist, but they just autofill the search expression.

DannyBen avatar May 18 '20 14:05 DannyBen

interesting. thx for pointing this out.

mrkamel avatar May 18 '20 14:05 mrkamel

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:

  1. The entire expression is in the URL
  2. The buttons on top change the expression
  3. 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:

  1. The developers are not asked every day to "add another search feature / field"
  2. The UI guys can create buttons and select boxes to inject phrases to the expression
  3. The average user has a nice UI
  4. 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.

DannyBen avatar May 31 '20 12:05 DannyBen