Skip to content

Commit 91bd2d1

Browse files
committed
Remove the usage of create_index() to use index() instead
1 parent 0c7f4fa commit 91bd2d1

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

scraper/src/meilisearch_helper.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class MeiliSearchHelper:
100100

101101
def __init__(self, host_url, api_key, index_uid, custom_settings):
102102
self.meilisearch_client = meilisearch.Client(host_url, api_key)
103-
self.meilisearch_index = self.__delete_and_create_index(index_uid)
103+
self.meilisearch_index = self.meilisearch_client.index(index_uid)
104104
self.add_settings(MeiliSearchHelper.SETTINGS, custom_settings)
105105

106106
def add_settings(self, default_settings, custom_settings):
@@ -122,14 +122,6 @@ def add_records(self, records, url, from_sitemap):
122122
'\033[{}m> Docs-Scraper: \033[0m{}\033[93m {} records\033[0m)'.format(
123123
color, url, record_count))
124124

125-
def __delete_and_create_index(self, index_uid):
126-
try:
127-
self.meilisearch_client.index(index_uid).delete()
128-
except Exception:
129-
print("The index " + index_uid + " does not exist. Creating...")
130-
131-
return self.meilisearch_client.create_index(index_uid, {'primaryKey': 'objectID'})
132-
133125
# Algolia's settings:
134126
# {"minWordSizefor1Typo"=>3,
135127
# "minWordSizefor2Typos"=>7,

0 commit comments

Comments
 (0)