fix compare_indexes for text indexes #1751
This commit is contained in:
parent
8cd536aab5
commit
08b6433843
@ -967,8 +967,16 @@ class Document(BaseDocument):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
required = cls.list_indexes()
|
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]
|
missing = [index for index in required if index not in existing]
|
||||||
extra = [index for index in existing if index not in required]
|
extra = [index for index in existing if index not in required]
|
||||||
|
|
||||||
|
@ -192,7 +192,13 @@ class ClassMethodsTest(unittest.TestCase):
|
|||||||
|
|
||||||
class Doc(Document):
|
class Doc(Document):
|
||||||
a = StringField()
|
a = StringField()
|
||||||
meta = { 'indexes': ['$a']}
|
b = StringField()
|
||||||
|
meta = {'indexes': [
|
||||||
|
{'fields': ['$a', "$b"],
|
||||||
|
'default_language': 'english',
|
||||||
|
'weights': {'a': 10, 'b': 2}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
|
||||||
Doc.drop_collection()
|
Doc.drop_collection()
|
||||||
Doc.ensure_indexes()
|
Doc.ensure_indexes()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user