# How to search \\t \\r \\n in elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-search-t-r-n-in-elasticsearch/278984>\
**Category:** Elasticsearch\
**Created:** [July 18, 2021, 9:46am UTC](https://discuss.elastic.co/t/how-to-search-t-r-n-in-elasticsearch/278984 "2021-07-18T09:46:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarvinLiu](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@MarvinLiu](https://discuss.elastic.co/u/MarvinLiu)\
**Post date:** [July 18, 2021, 9:46am UTC](https://discuss.elastic.co/t/how-to-search-t-r-n-in-elasticsearch/278984/1 "2021-07-18T09:46:28Z")

</div>

I want to search \t \r \n in my doc, how to input in query string syntax.

It seems "\n" can work , "\n","\n" not work ,  
Is there any other choises?

```auto
POST /test6/_doc/2
{
    "id": 1002,
    "name": "test1",
    "desc": "Marvin \n \t \r "
}
POST test6/_close  
POST test6/_open  
PUT /test6/_settings
{
            "analysis": {
                "analyzer": {
                    "default": {
                        "tokenizer": "default",
                        "filter": null
                    }
                },
                "tokenizer": {
                    "default": {
                        "type": "char_group",
                        "tokenize_on_chars": [
                            " "
                        ]
                    }
                }
            }
}

POST test6/_search
{"query":{"query_string":{"query":"\\t"}}
}
POST test6/_search
{"query":{"query_string":{"query":"\"\t\""}}
}
POST test6/_search
{"query":{"query_string":{"query":"\t"}}
}
POST test6/_search
{"query":{"query_string":{"query":"Marvin"}}
}

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 19, 2021, 9:14am UTC](https://discuss.elastic.co/t/how-to-search-t-r-n-in-elasticsearch/278984/2 "2021-07-19T09:14:23Z")

</div>

You need to configure the analyzer for a field before indexing your data (at best at index creation), as otherwise those characters are not stored in the inverted index. You only have configured your analyzer to be in the index configuration, but it is not applide to any field. Side note: You could go with the `whitespace` tokenizer as well.

Out of curiosity: What problem are you solving in order to be able to search for control characters? Can you add some more context about the use-case?

---

<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:** [August 18, 2021, 8:31am UTC](https://discuss.elastic.co/t/how-to-search-t-r-n-in-elasticsearch/278984/4 "2021-08-18T08:31:19Z")

</div>

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