mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
First basic working solr search
This commit is contained in:
@ -1,19 +0,0 @@
|
||||
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)
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ trait FtsClient[F[_]] {
|
||||
*/
|
||||
def initialize: F[Unit]
|
||||
|
||||
def searchBasic(q: FtsQuery): Stream[F, FtsBasicResult]
|
||||
def searchBasic(q: FtsQuery): Stream[F, FtsResult]
|
||||
|
||||
def indexData(logger: Logger[F], data: Stream[F, TextData]): F[Unit]
|
||||
}
|
||||
|
@ -7,4 +7,4 @@ import docspell.common._
|
||||
* 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)
|
||||
final case class FtsQuery(q: String, collective: Ident, limit: Int, offset: Int, items: List[Ident])
|
||||
|
@ -0,0 +1,28 @@
|
||||
package docspell.ftsclient
|
||||
|
||||
import docspell.common._
|
||||
|
||||
import FtsResult.ItemMatch
|
||||
|
||||
final case class FtsResult(
|
||||
qtime: Duration,
|
||||
count: Int,
|
||||
maxScore: Double,
|
||||
highlight: Map[Ident, List[String]],
|
||||
results: List[ItemMatch]
|
||||
) {}
|
||||
|
||||
object FtsResult {
|
||||
|
||||
sealed trait MatchData
|
||||
case class AttachmentData(attachId: Ident) extends MatchData
|
||||
case object ItemData extends MatchData
|
||||
|
||||
case class ItemMatch(
|
||||
id: Ident,
|
||||
itemId: Ident,
|
||||
collectiveId: Ident,
|
||||
score: Double,
|
||||
data: MatchData
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user