정적 방법으로 부모 클래스의 전체 텍스트 검색을 수행하는 동안 오류 및플라스크/Mongoengine : 나는 아이템 클래스를 생성 한
class Item(db.Document):
name = db.StringField()
slug = db.StringField()
description = db.StringField()
content = db.StringField()
start_time = db.DateTimeField()
end_time = db.DateTimeField()
@staticmethod
def search_static(keywords):
return Item.objects.search_text(keywords).order_by('$text_score')
@classmethod
def search_class(cls,keywords):
return cls.objects.search_text(keywords).order_by('$text_score')
meta = {
'allow_inheritance' : True,
'indexes' : [
{
'fields': ['$name','$slug','$description','$content'],
'default_language':'french',
'weights': {'name': 10, 'slug': 10 , 'description': 5, 'content': 5}
}
]
}
class Item1(Item):
item_type = db.ReferenceField('T1')
class Item2(Item):
item_type = db.ReferenceField('T2')
class T1(db.Document):
name = db.StringField()
class T2(db.Document):
name = db.StringField()
다음 아래와 같이 두 개의 서브 클래스 항목 1과 항목 2, 내가 만들어 내가 클래스 메소드
>>> Item1.search_class("dog")
[<Item1: Item1 object>, <Item1: Item1 object>]
>>> Item1.search_class("viper")
[<Item1: Item1 object>]
>>> Item2.search_class("viper")
[<Item2: Item2 object>]
>>> Item2.search_class("tiger")
[]
>>>
,536,913,632에게 테스트있을 때 일부 항목
Results in mongo shell of following commands db.item.find()/db.t1.find()/db.t2.find()
다 괜찮습니다
>>> Item.search_static("tiger")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/venv/lib/python2.7/site-packages/mongoengine/queryset/queryset.py", line 58, in __repr__
self._populate_cache()
File "/venv/lib/python2.7/site-packages/mongoengine/queryset/queryset.py", line 92, in _populate_cache
self._result_cache.append(self.next())
File "/venv/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 1407, in next
raw_doc = self._cursor.next()
File "/venv/lib/python2.7/site-packages/pymongo/cursor.py", line 1090, in next
if len(self.__data) or self._refresh():
File "/venv/lib/python2.7/site-packages/pymongo/cursor.py", line 1012, in _refresh
self.__read_concern))
File "/venv/lib/python2.7/site-packages/pymongo/cursor.py", line 905, in __send_message
helpers._check_command_response(doc['data'][0])
File "/venv/lib/python2.7/site-packages/pymongo/helpers.py", line 196, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: error processing query: ns=archives_flask.itemTree: $and
_cls $in [ "Item" "Item.Item1" "Item.Item2" ]
TEXT : query=tiger, language=french, caseSensitive=0, diacriticSensitive=0, tag=NULL
Sort: { _text_score: { $meta: "textScore" } }
Proj: { _text_score: { $meta: "textScore" } }
planner returned error: failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)
>>>
당신이 어떤 아이디어 나 조언을 도와 주 시겠어요 : 나는 (한 번에 모든 서브 클래스에서 검색하기 위해) 정적 메소드를 사용하고자 할 때 10
그러나, 나는이 몽고 오류가?