SergeyKlimov

Пример создания индекса с поддержкой русского языка. BULK не работает :-(

Jul 23rd, 2021
1,481
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. es_settings = {
  2.  "refresh_interval": "1s",
  3.  "analysis": {
  4.      "filter": {
  5.          "russian_stop": {"type": "stop", "stopwords": "_russian_"},
  6.          "russian_stemmer": {
  7.              "type": "stemmer",
  8.              "language": "russian"
  9.          }
  10.      },
  11.      "analyzer": {
  12.          "ru": {
  13.              "tokenizer": "standard",
  14.              "filter": ["lowercase", "russian_stop","russian_stemmer"]
  15.          }
  16.      }
  17.  }
  18. }
  19. es_mappings = {
  20.     "dynamic": "strict",
  21.     "properties": {
  22.         "text_field": {"type": "text","analyzer": "ru"},
  23.         "number": {"type": "long"}
  24.     }
  25. }
  26. es.indices.create(index=index_movies, body={'settings': es_settings, 'mappings': es_mappings}, ignore=400)
RAW Paste Data