Initial module setup

This commit is contained in:
Eike Kettner
2020-06-14 22:53:20 +02:00
parent 492f4d304f
commit c7f598e3b0
8 changed files with 154 additions and 1 deletions

View File

@ -0,0 +1,19 @@
package docspell.ftsclient
import cats.data.NonEmptyList
import cats.implicits._
import docspell.common._
import FtsBasicResult.AttachmentMatch
final case class FtsBasicResult(item: Ident, attachments: NonEmptyList[AttachmentMatch]) {
def score: Double =
attachments.map(_.score).toList.max
}
object FtsBasicResult {
case class AttachmentMatch(id: Ident, score: Double)
}

View File

@ -0,0 +1,18 @@
package docspell.ftsclient
import fs2.Stream
/** The fts client is the interface for docspell to a fulltext search
* engine.
*
* It defines all operations required for integration into docspell.
* It uses data structures and terms of docspell. Implementation
* modules need to translate it to the engine that provides the
* features.
*/
trait FtsClient[F[_]] {
def searchBasic(q: FtsQuery): Stream[F, FtsBasicResult]
def indexData(data: TextData): F[Unit]
}

View File

@ -0,0 +1,10 @@
package docspell.ftsclient
import docspell.common._
/** A fulltext query.
*
* The query itself is a raw string. Each implementation may
* interpret it according to the system in use.
*/
final case class FtsQuery(q: String, collective: Ident, limit: Int, offset: Int)

View File

@ -0,0 +1,5 @@
package docspell.ftsclient
import docspell.common._
final case class TextData(item: Ident, attachment: Ident, collective: Ident, text: String)