Create search index java + Spring-boot + MongoCK

Hi,

We use Java 11+ Spring-boot 2.6.0 and MongoCk.

We want to create search index automatically with mongock.

It’s possible to create with MongoTemplate (MongoTemplate (Spring Data MongoDB 3.4.0 API)) the search index?

Regards, Tobias

Hi @Tobias_Letschka and welcome in the MongoDB Community :muscle: !

Atlas Search is a MongoDB Atlas specific feature that’s not available elsewhere because it requires some extra servers & config to host the Lucene indexes + sync processes (transparent for the users).

MongoTemplate is specific to MongoDB but not Atlas specific features. So I doubt it’s supported directly in there.

Also, it’s also not possible to create an Atlas Search index directly from a MongoDB supported driver (for the same reasons).

Currently, if you want to create an Atlas Search index, you have to create it using the:

  • Atlas UI
  • Atlas Search API
  • Atlas CLI

See the doc:

If Mongock supports API calls, I would probably use Atlas Search API. If it supports system calls, you can use the Atlas CLI.

Cheers,
Maxime.

2 Likes

Hi @MaBeuLux88 thank you the response. It was really helpful.

Regards, Tobias

1 Like

Hi from Mongock team,

Just wanted to add that Mongock supports API calls as well as system calls, so you shouldn’t have any problem with this.

1 Like

Hi @Antonio_Perez_Dieppa ,

do you have any example?

Hi @Tobias_Letschka ,

what I meant is that Mongock doesn’t stop you from using whatever you want to use(MongoTemplate, MongoDatabase, Custom repositories or any other dependency). If you are using Springboot, you just need to inject it into the Spring context and use it in the Mongock ChangeUnit(legacy ChangeLog) as you would do with the MongoTemplate.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.