Стоп-слова

Я использую elasticsearch php.

$this->client->indices()->create([
            'index' => 'kmr',
            'body' => [
                'mappings' => [
                    'deputy' => [
                        '_source' => [
                            'enabled' => true,
                        ],
                        'properties' => [
                            'id' => [
                                'type' => 'integer',
                            ],
                            'pib' => [
                                'type' => 'text',
                                'analyzer' => 'ukrainian'
                            ],
                            'constituency' => [
                                'type' => 'text',
                            ],
                            'list_address' => [
                                'type' => 'text',
                                'analyzer' => 'ukrainian'
                            ],
                        ],
                    ],
                ],
                'settings' => [
                    'analysis' => [
                        'char_filter' => [
                            'replace' => [
                                'type' => 'mapping',
                                'mappings' => [
                                    '&=> and '
                                ],
                            ],
                        ],
                        'filter' => [
                            'word_delimiter' => [
                                'type' => 'word_delimiter',
                                'split_on_numerics' => false,
                                'split_on_case_change' => true,
                                'generate_word_parts' => true,
                                'generate_number_parts' => true,
                                'catenate_all' => true,
                                'preserve_original' => true,
                                'catenate_numbers' => true,
                            ],
                            'trigrams' => [
                                'type' => 'ngram',
                                'min_gram' => 3,
                                'max_gram' => 20,
                            ],
                            'my_stop' => [
                                'type' => 'stop',
                                'stopwords' => ['вул.', 'вулиця', 'просп.', 'проспект', 'площа'],
                                'ignore_case' => true
                            ],
                        ],
                        'analyzer' => [
                            'ukrainian' => [
                                'type' => 'custom',
                                'char_filter' => [
                                    'html_strip',
                                    'replace',
                                ],
                                'tokenizer' => 'whitespace',
                                'filter' => [
                                    'lowercase',
                                    'word_delimiter',
                                    'trigrams',
                                    'my_stop'
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ]);

Сам индекс:

{
  "kmr": {
    "aliases": {},
    "mappings": {
      "deputy": {
        "properties": {
          "constituency": {
            "type": "text"
          },
          "id": {
            "type": "integer"
          },
          "list_address": {
            "type": "text"
          },
          "pib": {
            "type": "text"
          }
        }
      }
    },
    "settings": {
      "index": {
        "number_of_shards": "5",
        "provided_name": "kmr",
        "creation_date": "1534503382887",
        "analysis": {
          "filter": {
            "trigrams": {
              "type": "ngram",
              "min_gram": "3",
              "max_gram": "20"
            },
            "word_delimiter": {
              "split_on_numerics": "false",
              "generate_word_parts": "true",
              "preserve_original": "true",
              "generate_number_parts": "true",
              "catenate_all": "true",
              "split_on_case_change": "true",
              "type": "word_delimiter",
              "catenate_numbers": "true"
            },
            "my_stop": {
              "ignore_case": "true",
              "type": "stop",
              "stopwords": [
                "вул.",
                "вулиця",
                "просп.",
                "проспект",
                "площа"
              ]
            }
          },
          "analyzer": {
            "ukrainian": {
              "filter": [
                "lowercase",
                "word_delimiter",
                "trigrams",
                "my_stop"
              ],
              "char_filter": [
                "html_strip",
                "replace"
              ],
              "type": "custom",
              "tokenizer": "whitespace"
            }
          },
          "char_filter": {
            "replace": {
              "type": "mapping",
              "mappings": [
                "&=> and "
              ]
            }
          }
        },
        "number_of_replicas": "1",
        "uuid": "T8f2uWptT2iwJFHkWgB0OA",
        "version": {
          "created": "6030299"
        }
      }
    }
  }
}

Когда я делаю поиск, то получаю ответы со стоп словами.
Подскажите, что я делаю не так?

У вас анализатор для индекса определен, но ни одно поле его не использует.

Нашел ошибку:
Должно быть так (сначала 'my_stop', потом 'trigrams'):

'analyzer' => [
                            'ukrainian' => [
                                'type' => 'custom',
                                'char_filter' => [
                                    'html_strip',
                                    'replace',
                                ],
                                'tokenizer' => 'whitespace',
                                'filter' => [
                                    'lowercase',
                                    'word_delimiter',
                                    'my_stop',
                                    'trigrams'
                                ],
                            ],
                        ],

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