如何触发解析服务器创建文本索引?
How to trigger parse-server to create text index?
我的 parse-server
上的文本查询请求
curl -X GET \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-G \
--data-urlencode 'where={"name":{"$text":{"$search":{"$term":"Milk"}}}}' \
--data-urlencode 'order="$score"' \
--data-urlencode 'key="$score"' \
http://localhost:1337/parse/classes/Groceries
Returns 这个错误:
{"code":1,"error":{"name":"MongoError","message":"text index required for $text query","ok":0,"errmsg":"text index required for $text query","code":27,"codeName":"IndexNotFound"}}
如何解决这个问题?
来自http://docs.parseplatform.org/parse-server/guide/:
When using MongoDB with your Parse app, you need to manage your indexes yourself. You will also need to size up your database as your data grows.
"yourself" 在此上下文中意味着您需要使用您选择的客户端和 create the index 连接到 mongodb。类似于:
db.collection.createIndex(
{
field1: "text",
field2: "text",
etc...
}
)
我的 parse-server
上的文本查询请求curl -X GET \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-G \
--data-urlencode 'where={"name":{"$text":{"$search":{"$term":"Milk"}}}}' \
--data-urlencode 'order="$score"' \
--data-urlencode 'key="$score"' \
http://localhost:1337/parse/classes/Groceries
Returns 这个错误:
{"code":1,"error":{"name":"MongoError","message":"text index required for $text query","ok":0,"errmsg":"text index required for $text query","code":27,"codeName":"IndexNotFound"}}
如何解决这个问题?
来自http://docs.parseplatform.org/parse-server/guide/:
When using MongoDB with your Parse app, you need to manage your indexes yourself. You will also need to size up your database as your data grows.
"yourself" 在此上下文中意味着您需要使用您选择的客户端和 create the index 连接到 mongodb。类似于:
db.collection.createIndex(
{
field1: "text",
field2: "text",
etc...
}
)