# Unable to preserve special characters in search results of ElasticSearch

**URL:** <https://discuss.elastic.co/t/unable-to-preserve-special-characters-in-search-results-of-elasticsearch/22819>\
**Category:** Elasticsearch\
**Created:** [March 23, 2015, 11:35am UTC](https://discuss.elastic.co/t/unable-to-preserve-special-characters-in-search-results-of-elasticsearch/22819 "2015-03-23T11:35:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)\
**Post date:** [March 23, 2015, 11:35am UTC](https://discuss.elastic.co/t/unable-to-preserve-special-characters-in-search-results-of-elasticsearch/22819/1 "2015-03-23T11:35:01Z")

</div>

Hi,

I want to preserve the special characters like -, /, (, ) in search results.

Ex: Abc/def a(bc)def a-bcd  
response: If I enter Abc/ the records containing abc/ need to come, similarly for abc/def records with the following need to come, in the same way abc/def a(bc) records with the similar combination need to come.

For this I have used different analyzers and filters and the settings and mappings as follows:

PUT /facebook?pretty=true  
{  
"settings" : {  
"analysis" : {  
"filter" : {  
"special\_character\_spliter" : {  
"type" : "word\_delimiter",  
"preserve\_original": "true"  
}  
},  
"analyzer" : {  
"my\_an" : {  
"type" : "pattern",  
"pattern" : "[^(_/_-\*\w\p{L}]+",  
"tokenizer" : "whitespace",  
"filter" : ["special\_character\_spliter"]  
}  
}  
}  
},  
"mappings" : {  
"face" : {  
"properties" : {  
"msg" : {  
"type" : "string",  
"analyzer": "my\_an"

```
            },
            "name" : {
                "type" : "string"
            }
        }
    }
}

```

}

and even I have tried with the following settings also:

PUT facebook?pretty=true  
{  
"settings": {  
"index.number\_of\_replicas": 0,  
"analysis": {  
"analyzer": {  
"msg\_excp\_analyzer": {  
"type": "custom",  
"tokenizer": "whitespace",  
"filters": ["my\_word\_delimiter","my\_word\_pattern",  
"lowercase",  
"asciifolding",  
"shingle",  
"standard"]  
}  
},  
"filters": {  
"my\_word\_pattern":  
{  
"type" : "pattern\_capture",  
"preserve\_original" : 1,  
"patterns" : [  
"(\w+)",  
"(\p{L}+)",  
"(\d+)",  
"@(.+)"  
]

```
            },
            "my_word_delimiter": {
                "type": "word_delimiter",
                "preserve_original": "true",
                  "catenate_all": "true",
                  "type_table": {
                    "$": "DIGIT",
                    "%": "DIGIT",
                    ".": "DIGIT",
                    ",": "DIGIT",
                    ":": "DIGIT",
                    "/": "DIGIT",
                    "\\": "DIGIT",
                    "=": "DIGIT",
                    "&": "DIGIT",
                    "(": "DIGIT",
                    ")": "DIGIT",
                    "<": "DIGIT",
                    ">": "DIGIT",
                    "\\U+000A": "DIGIT"

            },
            "my_asciifolding": {
                "type": "asciifolding",
                "preserve_original": true
            }
        }
    }
}
},
"mappings": {
    "face": {
        "properties": {
            "msg": {
                "type": "string",
                "index": "analyzed",
                "analyzer": "msg_excp_analyzer"
            },
            "name": {
                "type": "string",
                "index": "analyzed",
                "analyzer": "msg_excp_analyzer"
            }
        }
    }
}

```

}

With above settings I have tried separately inorder to preserve the special characters in search results,  
and i have used query like:

GET facebook/face/\_search  
{

"query": {  
"bool": {  
"must": [  
{  
"query\_string": {  
"fields": [  
"msg"  
],  
"query": "a/"  
}  
}  
]  
}

```
}

```

}

Am getting the following error:

"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[trVZmtb4Qu-QWIqxK5hEfg][facebook][0]: SearchParseException[[facebook][0]:

May I know what is the problem with , whether is it with my query or settings?

---

<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:24am UTC](https://discuss.elastic.co/t/unable-to-preserve-special-characters-in-search-results-of-elasticsearch/22819/2 "2017-07-06T00:24:53Z")

</div>


