# Partial search of attributes(Substring, Case insensitive and special chars included)

**URL:** <https://discuss.elastic.co/t/partial-search-of-attributes-substring-case-insensitive-and-special-chars-included/214883>\
**Category:** Elasticsearch\
**Created:** [January 13, 2020, 5:49pm UTC](https://discuss.elastic.co/t/partial-search-of-attributes-substring-case-insensitive-and-special-chars-included/214883 "2020-01-13T17:49:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shail](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@Shail](https://discuss.elastic.co/u/Shail)\
**Post date:** [January 13, 2020, 5:49pm UTC](https://discuss.elastic.co/t/partial-search-of-attributes-substring-case-insensitive-and-special-chars-included/214883/1 "2020-01-13T17:49:32Z")

</div>

We are using ElasticSearch version 7.2 in our project with following characteristics:

1. The main index mapping contains attributes, embedded objects as well as few nested (array) types.
2. Analyzer : Standard analyzer

The requirement is to be able to perform partial search such that it supports

1. Case insensitive  
e.g. “name”: “John Doe” should match a search query like “name”: “john doe”

2. Patterns based like   
e.g. “name”: “John Doe” should match a search query like “name”: “_ohn D_”

3. Special characters(atleast the ones on standard English keyboard)  
e.g. “name”: “John (star) Doe” should match a search query like “name”: “_john (star_”

We have tried using the

1. match
2. wildcard
3. match\_phrase\_prefix
4. and query\_string  
but none of the above satisfies all the above 3 requirements together.

Is there any specific query DSL that can fulfill our requirements ?

---

<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:** [January 14, 2020, 8:41am UTC](https://discuss.elastic.co/t/partial-search-of-attributes-substring-case-insensitive-and-special-chars-included/214883/2 "2020-01-14T08:41:19Z")

</div>

Hey,

you should take some time to read about analysis and mapping. `ngrams` might be interesting to you for partial matches. Only when the data is indexed in the right way, your queries have the possibility to work as intended.

Even though it is a bit old already, [The Definitive Guide's "Search in Depth" chapter](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/search-in-depth.html) is a great resource on such topics.

--Alex

---

<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:** [February 11, 2020, 8:41am UTC](https://discuss.elastic.co/t/partial-search-of-attributes-substring-case-insensitive-and-special-chars-included/214883/3 "2020-02-11T08:41:36Z")

</div>

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