# Leerzeichen in der Suche mit Unterstrichen im Text ersetzen

**URL:** https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795
**Category:** Feature
**Created:** [12. März 2018 um 13:50 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795 "2018-03-12T13:50:46Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [12. März 2018 um 13:50 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/1 "2018-03-12T13:50:46Z")

</div>

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"`?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [13. März 2018 um 04:57 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/2 "2018-03-13T04:57:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![maja](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maja/32/129533_2.png) [@maja](https://meta.discourse.org/u/maja)
#### Post date: [21. März 2018 um 22:51 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/3 "2018-03-21T22:51:43Z")

</div>

I have added this feature [FEATURE: Match spaces in search with underscores in text by majakomel · Pull Request #5690 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/5690)

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.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [21. März 2018 um 22:55 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/4 "2018-03-21T22:55:26Z")

</div>

> [@maja](#):
>
> search term match the text where any word separators are used,

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)

---

<div class="post-metadata">

### Author: ![maja](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maja/32/129533_2.png) [@maja](https://meta.discourse.org/u/maja)
#### Post date: [21. März 2018 um 23:01 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/5 "2018-03-21T23:01:12Z")

</div>

> [@tophee](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [22. März 2018 um 20:37 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/6 "2018-03-22T20:37:30Z")

</div>

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”.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [22. März 2018 um 22:20 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/7 "2018-03-22T22:20:22Z")

</div>

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

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/a/1ad9776f4616881583a7f7deeaf91dc775843ae4.png)

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

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [22. März 2018 um 22:40 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/8 "2018-03-22T22:40:11Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [22. März 2018 um 22:41 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/9 "2018-03-22T22:41:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [22. März 2018 um 22:45 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/10 "2018-03-22T22:45:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [22. März 2018 um 22:48 UTC](https://meta.discourse.org/t/match-spaces-in-search-with-underscores-in-text/82795/11 "2018-03-22T22:48:33Z")

</div>


