mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Setup solr schema and index all data using a system task
The task runs on application start. It sets the schema using solr's schema api and then indexes all data in the database. Each step is memorized so that it is not executed again on subsequent starts.
This commit is contained in:
@ -373,6 +373,7 @@ docspell.joex {
|
||||
}
|
||||
solr = {
|
||||
url = "http://localhost:8983/solr/docspell_core"
|
||||
commit-within = 1000
|
||||
}
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@ final class JoexAppImpl[F[_]: ConcurrentEffect: ContextShift: Timer](
|
||||
private def scheduleBackgroundTasks: F[Unit] =
|
||||
HouseKeepingTask
|
||||
.periodicTask[F](cfg.houseKeeping.schedule)
|
||||
.flatMap(pstore.insert) *> IndexTask.job.flatMap(queue.insert)
|
||||
.flatMap(pstore.insert) *> IndexTask.job.flatMap(queue.insertIfNew)
|
||||
}
|
||||
|
||||
object JoexAppImpl {
|
||||
|
@ -42,7 +42,7 @@ object IndexTask {
|
||||
now,
|
||||
systemGroup,
|
||||
Priority.Low,
|
||||
None
|
||||
Some(taskName)
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -57,22 +57,23 @@ object Migration {
|
||||
_ <- OptionT.liftF(ctx.logger.info(s"Apply ${m.version}/${m.description}"))
|
||||
rec <- OptionT(insertRecord)
|
||||
res <- OptionT.liftF(m.task.run(ctx).attempt)
|
||||
_ <- OptionT.liftF(res match {
|
||||
ret <- OptionT.liftF(res match {
|
||||
case Right(()) => ().pure[F]
|
||||
case Left(ex) =>
|
||||
ctx.logger.error(ex)(
|
||||
s"Applying index migration ${m.version}/${m.description} failed"
|
||||
) *>
|
||||
ctx.store.transact(RFtsMigration.deleteById(rec.id)) *> Effect[F].raiseError(
|
||||
ex
|
||||
)
|
||||
ctx.store.transact(RFtsMigration.deleteById(rec.id)) *> Effect[F]
|
||||
.raiseError[Unit](
|
||||
ex
|
||||
)
|
||||
})
|
||||
} yield ()).getOrElseF(
|
||||
} yield ret).getOrElseF(
|
||||
ctx.logger.info(s"Migration ${m.version}/${m.description} already applied.")
|
||||
)
|
||||
}
|
||||
|
||||
def migrationTasks[F[_]]: List[Migration[F]] =
|
||||
def migrationTasks[F[_]: Effect]: List[Migration[F]] =
|
||||
List(
|
||||
Migration[F](1, solrEngine, "initialize", Kleisli(ctx => ctx.fts.initialize)),
|
||||
Migration[F](
|
||||
|
Reference in New Issue
Block a user