# Search eith string\_query for special charcters in not\_analyzed fields

**URL:** <https://discuss.elastic.co/t/search-eith-string-query-for-special-charcters-in-not-analyzed-fields/20966>\
**Category:** Elasticsearch\
**Created:** [November 27, 2014, 6:55am UTC](https://discuss.elastic.co/t/search-eith-string-query-for-special-charcters-in-not-analyzed-fields/20966 "2014-11-27T06:55:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas\_lodde](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@andreas\_lodde](https://discuss.elastic.co/u/andreas_lodde)\
**Post date:** [November 27, 2014, 6:55am UTC](https://discuss.elastic.co/t/search-eith-string-query-for-special-charcters-in-not-analyzed-fields/20966/1 "2014-11-27T06:55:05Z")

</div>

Hello,

I am storing strings containing special characters in a not\_analyzed field.  
In order to search with query\_string on this field I am escaping the  
special characters. I tried tow approach. But both seem to work only  
partially:

QueryParser.escape(value)

and

String regex = "([+\-!\(\){}\[\]^"~\*?:\\]|[&\|]{2})";  
value = value.replaceAll(regex, "\\$1");

Escaping works fine for: -,/,'^

But not for: +,:,|,",\*,\

Is there a way that I can search for Strings containing these characters.

Thanks for you help,

Andreas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1bb63f9d-a43b-49e8-a0c5-928faeb2b023%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1bb63f9d-a43b-49e8-a0c5-928faeb2b023%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:47am UTC](https://discuss.elastic.co/t/search-eith-string-query-for-special-charcters-in-not-analyzed-fields/20966/2 "2017-07-06T00:47:19Z")

</div>


