Match spaces in search with underscores in text

When I searched for "enable local logins via email" (a site setting) an hour ago, I was surprised not to find a single post. Now I noticed that there actually are some posts containing enable_local_logins_via_email.

How about having search interpret spaces in a search term also as underscores, i.e. to return posts with enable_local_logins_via_email in a search for "enable local logins via email"?

8개의 좋아요

Agree this will make searching for site settings much easier pr-welcome

5개의 좋아요

I have added this feature FEATURE: Match spaces in search with underscores in text by majakomel · Pull Request #5690 · discourse/discourse · GitHub

I figured out that underscores are not escaped in exact term when searching "enable_local_logins_via_email", so it already matches variations with different word sepataratos like enable local logins via email or enable+local+logins+via+email, I assume this is intended?
With the change I added, spaces in the exact search term match the text where any word separators are used, not only underscores.

7개의 좋아요

Does it also work for mixed separators within the same search term? (though I’m not sure I can come up with a realistic example for that)

You mean if searching for "enable local logins via email" matches "enable+local_logins via-email"? It does.

4개의 좋아요

While we’re at it, I think it might also help if the search term with all dashes eliminated would be treated as equivalent with the search term. What I mean is: a search for “multi-site” should find multisite as if I had searched for “multisite”.

Maja I think that PR is a bit confusing, the change is actually required here:

Not for global search on the site. This is where we hit the issue regularly.

3개의 좋아요

I original thought @tophee was referring to the Site Settings too, but it turns out it already supports searching with spaces:

https://github.com/discourse/discourse/commit/a78458300481a4e4505b829a30ef73d52fdf9b04

then I re-read the OP:

When I searched for "enable local logins via email" (a site setting) an hour ago, I was surprised not to find a single post.

which led me to believe it is actually referring to /search page.

8개의 좋아요

I think we should just table this for now, I don’t feel the original request has much utility.

3개의 좋아요

Agree with you here. Removing pr-welcome from this.

My bad, I did not fully understand the request here and got confused, thanks @xrav3nz and sorry @maja

4개의 좋아요