我的strapi项目使用Mongo数据库。
Strapi版本: 3.0.0-beta.19.5
我试过:
有没有办法创建一个2 2dspere索引?
发布于 2020-04-17 05:09:16
我刚找到解决办法。我不得不查阅猫鼬文献 索引部分。
在strapi文档中,它们只说明'index'的值是布尔类型。这和猫鼬医生不同。实际上,model.settings.json结构遵循猫鼬文档。
因此,要创建2dsphere索引,只需在该字段的键" index“中指定"2dsphere”。
例如:
{
"kind": "collectionType",
"connection": "default",
"collectionName": "phone_stores",
"info": {
"name": "phoneStore"
},
"options": {
"increments": true,
"timestamps": true
},
"attributes": {
"car": {
"type": "integer",
"required": true
},
"userStoreId": {
"type": "objectId"
},
"location": {
"type": "json",
"index": "2dsphere" // <------ <1>
},
}
}如果指定了<1>,则将在此字段上创建单场指数。但是u也可以指定其他类型的索引,就像我使用'2dsphere‘一样。
更新
我说的话
还可以指定其他类型的索引。
是不对的由于框架的原因,索引类型是有限的。到目前为止,我已经用2dsphere进行了测试,它正在工作。我还测试了text索引,但是它没有工作。
https://stackoverflow.com/questions/61263387
复制相似问题