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


(Aleksey) #1

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!


(system) #2