class Tag(db.Document):
text = db.StringField(unique=True)
class Post(db.Document):
user = db.ReferenceField(User, required=True)
pid = db.SequenceField(required=True, unique=True)
description = db.StringField()
title = db.StringField(required=True)
created = db.DateTimeField(default=utils.time_now, required=True)
updated = db.DateTimeField(default=utils.time_now, required=True)
tags = db.ListField(db.ReferenceField(Tag), default=[])
ratings = db.EmbeddedDocumentListField(Rating, default=[])
comments = db.EmbeddedDocumentListField(Comment, default=[])
url = db.URLField()
meta = {'indexes': [
{'fields': ['$title', '$description', '$tags.text'],
'default_language': 'english',
'weights': {'title': 10, 'description': 5, 'tags': 2}
}
]}
Here are my two documents. The Tag document is Referenced in a Listfield of the Post document. When I try to do a search with the text index I can successfully search on the title and description but not the tags. Does anyone know why. I couldn't find any helpful examples here http://docs.mongoengine.org/guide/text-indexes.html