from .search_client import INDEX, client, videos_index def setup_videos_index(): try: client.create_index(INDEX, {"primaryKey": "id"}) except Exception: print(Exception) index = videos_index() # Порядок = приоритет в ранжировании (attribute rule) index.update_searchable_attributes([ "title", "filename", "channel_name", "playlist_name", ]) index.update_filterable_attributes([ "channel_id", "playlist_id", "date", ]) index.update_sortable_attributes(["date", "id"]) index.update_displayed_attributes([ "id", "title", "filename", "date", "channel_id", "channel_name", "playlist_id", "playlist_name", "preview_path", ]) # Опционально: свежие выше при прочих равных index.update_ranking_rules([ "words", "typo", "proximity", "attribute", "date:desc", "exactness", ]) index.update_synonyms({ "python": ["питон", "пайтон"], "js": ["javascript", "джаваскрипт"], })