# Pattern analyzer doesn\`t work. What am I doing wrong?

**URL:** <https://discuss.elastic.co/t/pattern-analyzer-doesn-t-work-what-am-i-doing-wrong/60718>\
**Category:** Elasticsearch\
**Created:** [September 16, 2016, 1:38pm UTC](https://discuss.elastic.co/t/pattern-analyzer-doesn-t-work-what-am-i-doing-wrong/60718 "2016-09-16T13:38:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alekseydubinin](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@alekseydubinin](https://discuss.elastic.co/u/alekseydubinin)\
**Post date:** [September 16, 2016, 1:38pm UTC](https://discuss.elastic.co/t/pattern-analyzer-doesn-t-work-what-am-i-doing-wrong/60718/1 "2016-09-16T13:38:40Z")

</div>

Good day, everyone!

The task is german cities selecting. But there is a note, that rows for example " city (some\_land) " don`t have to be in results if the search string is like "lan", for example.

So, if we search for "bade", we have to receive Baden-Baden and not Karlsruhe (Baden).  
The 1st one is present, but the 2nd one either.

The analyzers and settings I have:

```
my_index:
      settings:
          analysis:
            filter:
                autocomplete_filter:
                  type: edge_ngram
                  min_gram: 3
                  max_gram: 10
                no_lands:
                    type: pattern_capture
                   patterns: ['([\w -]+(?![\([\w +\-]+\)]))']
              tokenizer:
                  no_lands_tokenizer:
                  type: pattern
                  pattern: '([\w -]+(?![\([\w +\-]+\)]))'
              analyzer:
                  no_lands:
                  tokenizer: no_lands_tokenizer
               autocomplete:
                  type: custom
                  tokenizer: standard
                  filter:
                    - standard
                    - lowercase
                    - autocomplete_filter
                    - no_lands

```

If I remove standard, lowercase and others - I`ll receive broken results for other cities.  
For example, "Berl" should return Berlin first, "Hann" - Hannover, etc.

regexp was checked through on-line regexp services, I`ve tried "should, must\_not", etc.  
Thanks!

---

<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, 10:19pm UTC](https://discuss.elastic.co/t/pattern-analyzer-doesn-t-work-what-am-i-doing-wrong/60718/2 "2017-07-05T22:19:39Z")

</div>

Closed on July 5, 2017, 10:19pm UTC


