404
mongodb
config_error
ai_generated
true
MongoServerError:此版本不支持geoHaystack索引
MongoServerError: geoHaystack index is not supported in this version
ID: mongodb/geo-haystack-index-not-supported
90%修复率
90%置信度
1证据数
2023-06-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| mongodb 7.0 | active | — | — | — |
| mongodb 6.0 | active | — | — | — |
| mongodb 5.0 | active | — | — | — |
根因分析
geoHaystack索引类型在MongoDB 5.0+中已被弃用并移除,但应用程序仍尝试创建或使用它。
English
The geoHaystack index type was deprecated and removed in MongoDB 5.0+, but the application still tries to create or use it.
官方文档
https://www.mongodb.com/docs/manual/release-notes/5.0-compatibility/#index-removal解决方案
-
用2dsphere索引替换geoHaystack:db.collection.createIndex({ location: '2dsphere' })并使用$nearSphere或$geoWithin查询。 -
如果需要边界框查询,使用带有$box的$geoWithin:db.places.find({ location: { $geoWithin: { $box: [ [0,0], [10,10] ] } } })
无效尝试
常见但无效的做法:
-
70% 失败
Downgrading is not recommended and may cause data compatibility issues.
-
95% 失败
No such flag exists; the feature is completely removed.