# Substring search for all the fields

**URL:** <https://discuss.elastic.co/t/substring-search-for-all-the-fields/11012>\
**Category:** Elasticsearch\
**Created:** [March 5, 2013, 11:27am UTC](https://discuss.elastic.co/t/substring-search-for-all-the-fields/11012 "2013-03-05T11:27:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea\_crotti](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@andrea\_crotti](https://discuss.elastic.co/u/andrea_crotti)\
**Post date:** [March 5, 2013, 11:27am UTC](https://discuss.elastic.co/t/substring-search-for-all-the-fields/11012/1 "2013-03-05T11:27:19Z")

</div>

So I've been struggling with partial matches, and I found this very nice  
link:

[http://mnylen.tumblr.com/post/22963609412/elasticsearch-and-a-simple-contains-search](http://mnylen.tumblr.com/post/22963609412/elasticsearch-and-a-simple-contains-search)

which does exactly what I want, but only one problem, I want that behaviour  
by default for _every field_..  
I can't find a way to get it done though, there must be a way to not be  
forced to do it for every field right?  
I tried something like this for example but it also doesn't work

```
        mapping = {
            index: {
                "properties": {
                    "default": {
                    "type": "string",
                    "search_analyzer": "str_search_analyzer",
                    "index_analyzer": "str_index_analyzer",
                    }
                }
            }
        }

```

Any hint?

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Runar\_Myklebust](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@Runar\_Myklebust](https://discuss.elastic.co/u/Runar_Myklebust)\
**Post date:** [March 6, 2013, 11:36am UTC](https://discuss.elastic.co/t/substring-search-for-all-the-fields/11012/2 "2013-03-06T11:36:16Z")

</div>

You could set the str\_search\_analyzer and str\_index\_analyzer as default:

"analyzer": {  
"default\_index": {  
"tokenizer": "keyword",  
"filter": ["lowercase", "asciifolding"]  
},  
"default\_search": {  
"tokenizer": "keyword",  
"filter": ["lowercase", "asciifolding"]  
}  
}

Or you could create a dynamic mapping for all fields, e.g

"dynamic\_templates": [  
{  
{  
"template\_all\_field": {  
"match": "\*",  
"mapping": {  
"type": "string",  
"search\_analyzer": "str\_search\_analyzer",  
"index\_analyzer": "str\_index\_analyzer",

```
                }
            }
        }
    ]

```

--  
Runar Myklebust  
Enonic AS

> **[Content Platform with Proven Track Record](https://www.enonic.com)**
>
> Enonic is the largest Norwegian CMS vendor with a long track record delivering to some of the most important brands and organizations in Norway.

On Tue, Mar 5, 2013 at 12:27 PM, andrea crotti [andrea.crotti.0@gmail.com](mailto:andrea.crotti.0@gmail.com)wrote:

> So I've been struggling with partial matches, and I found this very nice  
> link:
> 
> [http://mnylen.tumblr.com/post/22963609412/elasticsearch-and-a-simple-contains-search](http://mnylen.tumblr.com/post/22963609412/elasticsearch-and-a-simple-contains-search)
> 
> which does exactly what I want, but only one problem, I want that  
> behaviour by default for _every field_..  
> I can't find a way to get it done though, there must be a way to not be  
> forced to do it for every field right?  
> I tried something like this for example but it also doesn't work
> 
> ```
> mapping = {
> index: {
> "properties": {
> "default": {
> "type": "string",
> "search_analyzer": "str_search_analyzer",
> "index_analyzer": "str_index_analyzer",
> }
> }
> }
> }
> 
> ```
> 
> Any hint?
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:48am UTC](https://discuss.elastic.co/t/substring-search-for-all-the-fields/11012/3 "2017-07-06T02:48:07Z")

</div>


