Use no-op fts-client if disabled + push this flag to the webui

This commit is contained in:
Eike Kettner
2020-06-21 21:06:08 +02:00
parent 330fdcdd5b
commit cfe5aa8894
10 changed files with 88 additions and 18 deletions

View File

@ -1,6 +1,9 @@
package docspell.ftsclient
import fs2.Stream
import cats.implicits._
import cats.effect._
import org.log4s.getLogger
import docspell.common._
/** The fts client is the interface for docspell to a fulltext search
@ -90,3 +93,29 @@ trait FtsClient[F[_]] {
def clear(logger: Logger[F], collective: Ident): F[Unit]
}
object FtsClient {
def none[F[_]: Sync] =
new FtsClient[F] {
private[this] val logger = Logger.log4s[F](getLogger)
def initialize: F[Unit] =
logger.info("Full-text search is disabled!")
def search(q: FtsQuery): F[FtsResult] =
logger.warn("Full-text search is disabled!") *> FtsResult.empty.pure[F]
def updateIndex(logger: Logger[F], data: Stream[F, TextData]): F[Unit] =
logger.warn("Full-text search is disabled!")
def indexData(logger: Logger[F], data: Stream[F, TextData]): F[Unit] =
logger.warn("Full-text search is disabled!")
def clearAll(logger: Logger[F]): F[Unit] =
logger.warn("Full-text search is disabled!")
def clear(logger: Logger[F], collective: Ident): F[Unit] =
logger.warn("Full-text search is disabled!")
}
}

View File

@ -13,7 +13,7 @@ import docspell.common._
final case class FtsQuery(
q: String,
collective: Ident,
items: List[Ident],
items: Set[Ident],
limit: Int,
offset: Int
) {

View File

@ -14,6 +14,9 @@ final case class FtsResult(
object FtsResult {
val empty =
FtsResult(Duration.millis(0), 0, 0.0, Map.empty, Nil)
sealed trait MatchData
case class AttachmentData(attachId: Ident) extends MatchData
case object ItemData extends MatchData