Include preliminary support for text indexes

To index a text field, prefix the field name with `$`, as in `$title`.
This commit is contained in:
Clay McClure
2014-05-29 19:06:51 -04:00
parent cfbb283f85
commit 74bd7c3744
5 changed files with 22 additions and 5 deletions

View File

@@ -680,15 +680,18 @@ class BaseDocument(object):
if isinstance(key, (list, tuple)):
continue
# ASCENDING from +,
# ASCENDING from +
# DESCENDING from -
# GEO2D from *
# TEXT from $
direction = pymongo.ASCENDING
if key.startswith("-"):
direction = pymongo.DESCENDING
elif key.startswith("*"):
direction = pymongo.GEO2D
if key.startswith(("+", "-", "*")):
elif key.startswith("$"):
direction = pymongo.TEXT
if key.startswith(("+", "-", "*", "$")):
key = key[1:]
# Use real field name, do it manually because we need field