quarkusquarkus-panache

Mongo Indexing with Quarkus Panache


how would I go about creating an index for my collections in Panache. The documentation only touches on the most basic operations here.

For example I have a collection of events and I want to create an Index for the location so I can search for nearby events with something like $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')
    }
}

Cheers!


Solution

  • I don't think mongodb panache support creating indexes (base on this github issue: https://github.com/quarkusio/quarkus/issues/9801) you have to integrate quarkus liquibase for the that.

    Here is the guide: https://quarkus.io/guides/liquibase-mongodb