# Correct analyzer for a field with backslash

**URL:** <https://discuss.elastic.co/t/correct-analyzer-for-a-field-with-backslash/225614>\
**Category:** Elasticsearch\
**Created:** [March 30, 2020, 5:43am UTC](https://discuss.elastic.co/t/correct-analyzer-for-a-field-with-backslash/225614 "2020-03-30T05:43:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaociocca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joaociocca/32/15827_2.png) [@joaociocca](https://discuss.elastic.co/u/joaociocca)\
**Post date:** [March 30, 2020, 5:43am UTC](https://discuss.elastic.co/t/correct-analyzer-for-a-field-with-backslash/225614/1 "2020-03-30T05:43:15Z")

</div>

So, I'm trying to setup a new index mapping with the correct analyzer for a Windows credential field, which has the format `domain\username`.

I want to be able to search for domain, username AND domain\username. But the default analyzer seems to ignore the backslash (meaning, if I try to search for domain\username it will search for "domain OR username" ignoring the backslash), and if I try the whitespace analyzer it seems to only match on domain\username.

Any tips?

---

<div class="post-metadata">

**Author:** ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)\
**Post date:** [March 30, 2020, 8:25am UTC](https://discuss.elastic.co/t/correct-analyzer-for-a-field-with-backslash/225614/2 "2020-03-30T08:25:27Z")

</div>

How about using pattern analyzer [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-analyzer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-analyzer.html)

---

<div class="post-metadata">

**Author:** ![joaociocca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joaociocca/32/15827_2.png) [@joaociocca](https://discuss.elastic.co/u/joaociocca)\
**Post date:** [March 30, 2020, 7:56pm UTC](https://discuss.elastic.co/t/correct-analyzer-for-a-field-with-backslash/225614/3 "2020-03-30T19:56:12Z")

</div>

that maybe could work... but I also asked about this on Stack and received a suggestion to use the path\_hierarchy, it worked perfectly!

`https://stackoverflow.com/questions/60924725/correct-analyzer-for-a-field-with-backslash/`

huh... the preview is showing a different post, for some reason? O.o

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 27, 2020, 7:56pm UTC](https://discuss.elastic.co/t/correct-analyzer-for-a-field-with-backslash/225614/4 "2020-04-27T19:56:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
