# Sub string search along with case Insensitive and special characters

**URL:** <https://discuss.elastic.co/t/sub-string-search-along-with-case-insensitive-and-special-characters/93390>\
**Category:** Elasticsearch\
**Created:** [July 17, 2017, 12:37pm UTC](https://discuss.elastic.co/t/sub-string-search-along-with-case-insensitive-and-special-characters/93390 "2017-07-17T12:37:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suresh\_Yerrarapu](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@Suresh\_Yerrarapu](https://discuss.elastic.co/u/Suresh_Yerrarapu)\
**Post date:** [July 17, 2017, 12:37pm UTC](https://discuss.elastic.co/t/sub-string-search-along-with-case-insensitive-and-special-characters/93390/1 "2017-07-17T12:37:09Z")

</div>

Hi There,

Is it possible to query(wildcard search) on index with case insensitive as well as special characters without lower casing the input data .

My requirements are below:  
a). Data contains small case, upper case and special characters.  
b). Query string(which may contain capital or small case), it should return the result irrespective of case. i.e input string "a" can match with both "a" and "A" .

**Example:**  
**_Data:_**  
1. Sampl,e  
2. samp-le  
3. SAmp&le  
4. sAmp%le

when the query with **\*sa\*** in elastic. It should be able to return: all the four Sampl,e, samp-le, SAmp&le, sAmp%le (irrespective of case).

when the query with **\*-\*** in elastic. It should be able to return: samp-le

when the query with **\*&\*** in elastic. It should be able to return: SAamp&le.

It should also work for remaining special characters too like(, %).

**In-order to solve above problem. I created Index like below.**

PUT my\_index  
{  
"index" : {  
"analysis" : {  
"analyzer" : {  
"default" : {  
"type" : "whitespace",  
"tokenizer" : "whitespace"  
}  
}  
}  
}  
}

**I created one type called _mytype_ with not analyzed fields.**

PUT my\_index/\_mapping/mytype  
{  
"properties": {  
"data": {  
"type":"keyword",  
"index":"not\_analyzed"

```
    }
}

```

}

**I loaded data like below into elastic server.**

POST my\_index/mytype/1  
{  
"data":"Sampl,e"  
}

POST my\_index/mytype/2  
{  
"data":"samp-le"  
}

POST my\_index/mytype/3  
{  
"data":"SAmp&le"  
}

POST my\_index/mytype/4  
{  
"data":"sAmp%le"  
}

\*\*my query is below for above data to search **_sa_** :  
GET my\_index/\_search  
{  
"query": {  
"query\_string": {  
"query": "\*sa\*"  
}  
}  
}

**RESULT:**  
It's only able to search: samp-le (String 2).

**Expected:**  
It should be return all the String from index which contains **sa**.

It's should be able to search all special characters.

What should I modify in schema or query, to get desired results(It should work for case insensitive as well as special characters)

**NOTE : Converting input data to lower case it's not solution to my case( I have to pass exact data to another component)**

Thanks in advance  
Suresh Y

---

<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 14, 2017, 12:37pm UTC](https://discuss.elastic.co/t/sub-string-search-along-with-case-insensitive-and-special-characters/93390/2 "2017-08-14T12:37:25Z")

</div>

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