algolia / hn-search

Hacker News Search
http://hn.algolia.com
Other
550 stars 74 forks source link

Requesting an excluding author/by syntax #212

Open dredmorbius opened 3 years ago

dredmorbius commented 3 years ago

Algolia supports searching posts or comments submitted by a specific user: by:<username or author:username.

It's not possible to search excluding a specific username.

E.g., to find mentions but not comments by tptacek, neither of these works as expected:

-by:tptacek tptacek
by:-tptacek tptacek

I'd expect these to return posts (or comments) mentioning but not by tptacek. Currently both return any content by or mentioning tptacek.

Of the two, I'd probably prefer the -by:<username> syntax.

Haroenv commented 3 years ago

This application has been created a long time ago, meaning that filters are done with "tags" and not via filters/facets, so negations aren't possible as far as I can tell.

Changing the indexing to allow that sounds a little too complicated for me to figure out for now, sorry!

Haroenv commented 3 years ago

The relevant part of the code that parses these prefixes is frontend today (here: https://github.com/algolia/hn-search/blob/951fd4f9f38c084677c8db8524edcee74d1aa06a/app/javascript/providers/SearchSettings.ts#L30)

dredmorbius commented 3 years ago

Seems that an author/by negation would be the same as returning a search set for the keyword, except that it would specificallly exclude any results tagged with the specified user.