Merge pull request #1790 from erdenezul/compare_index_correct_behavior_text

Compare_indexes correct behavior for text index
This commit is contained in:
erdenezul
2018-05-20 11:46:35 +08:00
committed by GitHub
2 changed files with 31 additions and 2 deletions

View File

@@ -967,8 +967,16 @@ class Document(BaseDocument):
"""
required = cls.list_indexes()
existing = [info['key']
for info in cls._get_collection().index_information().values()]
existing = []
for info in cls._get_collection().index_information().values():
if '_fts' in info['key'][0]:
index_type = info['key'][0][1]
text_index_fields = info.get('weights').keys()
existing.append(
[(key, index_type) for key in text_index_fields])
else:
existing.append(info['key'])
missing = [index for index in required if index not in existing]
extra = [index for index in existing if index not in required]