# What search to use?

**URL:** <https://discuss.elastic.co/t/what-search-to-use/36730>\
**Category:** Elasticsearch\
**Created:** [December 9, 2015, 11:07am UTC](https://discuss.elastic.co/t/what-search-to-use/36730 "2015-12-09T11:07:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Kruse\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefan_kruse_2/32/12005_2.png) [@Stefan\_Kruse\_2](https://discuss.elastic.co/u/Stefan_Kruse_2)\
**Post date:** [December 9, 2015, 11:07am UTC](https://discuss.elastic.co/t/what-search-to-use/36730/1 "2015-12-09T11:07:14Z")

</div>

Hi, i have the follow problem. In my elasticsearch index i have names like Festmacher,Festmacher - Emden,Festmacher - Bremerhaven,Festmacher - Hamburg,Festmacher - Bremen,Festmacher - Glückstad,Festmacher - Brunsbüttel etc. I use the match\_phrase query search. If i enter FEstmacher i found all names. If i enter fest i found nothing. Is there a way to make "like" search or "wildcard usage"? It would be great that when i enter "fest brem" i got all names back with these 2 words. Thanks for helping.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 9, 2015, 11:23am UTC](https://discuss.elastic.co/t/what-search-to-use/36730/2 "2015-12-09T11:23:03Z")

</div>

You can look at ngrams and adapt your mapping / analysis chain to meet your requirements.

---

<div class="post-metadata">

**Author:** ![Stefan\_Kruse\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefan_kruse_2/32/12005_2.png) [@Stefan\_Kruse\_2](https://discuss.elastic.co/u/Stefan_Kruse_2)\
**Post date:** [December 10, 2015, 1:20pm UTC](https://discuss.elastic.co/t/what-search-to-use/36730/3 "2015-12-10T13:20:22Z")

</div>

Hi, thanks for replay. I try it but dont get it to work right. I read the manual but there are some questions open. I want the ngram tokenizer only for one index type. Not for all types in my index. Is this possible? Do i have to create the index with the analyze settings first and then index or could i change the settings latter with putSettings? Because there i got error, could not change no dynmaic settings.

I think i have to read more the manual. But some hint would be great.  
Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Stefan\_Kruse\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefan_kruse_2/32/12005_2.png) [@Stefan\_Kruse\_2](https://discuss.elastic.co/u/Stefan_Kruse_2)\
**Post date:** [December 11, 2015, 8:13am UTC](https://discuss.elastic.co/t/what-search-to-use/36730/4 "2015-12-11T08:13:25Z")

</div>

Okay, i come closer to my wishes.  
My analysis settings looks like this:

```auto
'analysis' => [
                            'analyzer' => [                                
                                'apps_search' => [
                                    'type' => 'custom',
                                    'tokenizer' => 'keyword',
                                    'filter' => ['lowercase','substring']

                                ],
                                'apps_index' => [
                                    'type' => 'custom',
                                    'tokenizer' => 'keyword',
                                    'filter' => ['lowercase','substring']

                                ]                               
                            ],
                            'filter' => [
                                'substring' => [
                                    'type' => 'nGram',
                                    'min_gram' => '1',
                                    'max_gram' => '20',
                                    #'token_chars' => ['letter', 'digit', 'whitespace']
                                ]
                            ]                                    
                        ]

```

And my mapping looks like:

```auto
'mappings' => [
                        'subcategory' => [                            
                            'properties' => [
                                'name' => [
                                    'type' => 'string',
                                    #'index' => 'analyzed',
                                    'analyzer' => 'apps_index',
                                    'search_analyzer' => 'apps_search'
                                ]                            
                            ]
                        ]
                    ]

```

But when i know use a match\_phrase query like:

```auto
'query' => [
                        'match_phrase' => [
                            'name' => 'Festmacher'
                        ]
                    ]

```

the search return all names. Not only ones including "Festmacher".  
The next thing is: I need to look for word phrases. If i enter "fest brem" the search should return all names like "FEstmacher Bremen" , "Festmacher Bremerhaven" and so on. How could i make this happen?

Thanks Stefan

---

<div class="post-metadata">

**Author:** ![Stefan\_Kruse\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefan_kruse_2/32/12005_2.png) [@Stefan\_Kruse\_2](https://discuss.elastic.co/u/Stefan_Kruse_2)\
**Post date:** [December 11, 2015, 11:08am UTC](https://discuss.elastic.co/t/what-search-to-use/36730/5 "2015-12-11T11:08:33Z")

</div>

I try all search queries but without luck. What do i not see? There must be a little thing wrong. Why the search retuns all indexed names?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 11, 2015, 9:43pm UTC](https://discuss.elastic.co/t/what-search-to-use/36730/6 "2015-12-11T21:43:42Z")

</div>

The problem is that you are applying a ngram to what the user is entering.

So when you search for `fest` after analysis, it becomes `f`, `fe`, `fes`, `fest`.  
I guess that `f` matches a lot of docs.

I'd use a `simple` search\_analyzer.

---

<div class="post-metadata">

**Author:** ![Stefan\_Kruse\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefan_kruse_2/32/12005_2.png) [@Stefan\_Kruse\_2](https://discuss.elastic.co/u/Stefan_Kruse_2)\
**Post date:** [December 12, 2015, 8:30am UTC](https://discuss.elastic.co/t/what-search-to-use/36730/7 "2015-12-12T08:30:02Z")

</div>

Thanks for Reply. Sounds logical. Only one questions left.. How Can i set an Index Analyser in my Mapping . I dont found Something. Search Analyser is there but Index Analyser not .

---

<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 5, 2017, 11:31pm UTC](https://discuss.elastic.co/t/what-search-to-use/36730/8 "2017-07-05T23:31:34Z")

</div>


