Mongo 使用 Quarkus Panache 建立索引

Mongo Indexing with Quarkus Panache

我将如何在 Panache 中为我的 collection 创建索引。文档这里只涉及到最基本的操作。

例如,我有一个 collection 事件,我想为该位置创建一个索引,这样我就可以使用 $geoWithin:

之类的东西搜索附近的事件
{
    _id: ObjectId('61a6aec20e576d3cb4e0bbc0'),
    categories: [
        {
            _id: 'concert',
            name: 'concert'
        }
    ],
    name: 'Event title',
    description: 'Lorem ipsum',
    location: {
        coordinates: {
            lat: 51.53383166083413,
            lng: 9.946242556174917
        },
        type: 'Point'
    },
   
    time: {
        endTime: ISODate('2022-02-08T23:00:00.000Z'),
        startTime: ISODate('2022-02-08T16:00:00.000Z')
    }
}

干杯!

我认为 mongodb panache 不支持创建索引(基于这个 github 问题:https://github.com/quarkusio/quarkus/issues/9801)你必须为此集成 quarkus liquibase。

这是指南:https://quarkus.io/guides/liquibase-mongodb