mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Add a route that only searches the full-text index
It returns the results in the same order as received from the index to preserve the relevance ordering.
This commit is contained in:
@ -173,6 +173,11 @@ trait Conversions {
|
||||
ItemLightList(gs)
|
||||
}
|
||||
|
||||
def mkItemListWithTagsFtsPlain(v: Vector[OFulltext.FtsItemWithTags]): ItemLightList = {
|
||||
if (v.isEmpty) ItemLightList(Nil)
|
||||
else ItemLightList(List(ItemLightGroup("Results", v.map(mkItemLightWithTags).toList)))
|
||||
}
|
||||
|
||||
def mkItemLight(i: OItemSearch.ListItem): ItemLight =
|
||||
ItemLight(
|
||||
i.id,
|
||||
|
@ -83,6 +83,26 @@ object ItemRoutes {
|
||||
}
|
||||
} yield resp
|
||||
|
||||
case req @ POST -> Root / "searchIndex" =>
|
||||
for {
|
||||
mask <- req.as[ItemFtsSearch]
|
||||
resp <- mask.query match {
|
||||
case q if q.length > 1 =>
|
||||
val ftsIn = OFulltext.FtsInput(q)
|
||||
for {
|
||||
items <- backend.fulltext.findIndexOnly(
|
||||
ftsIn,
|
||||
user.account.collective,
|
||||
Batch(mask.offset, mask.limit).restrictLimitTo(cfg.maxItemPageSize)
|
||||
)
|
||||
ok <- Ok(Conversions.mkItemListWithTagsFtsPlain(items))
|
||||
} yield ok
|
||||
|
||||
case _ =>
|
||||
BadRequest(BasicResult(false, "Query string too short"))
|
||||
}
|
||||
} yield resp
|
||||
|
||||
case GET -> Root / Ident(id) =>
|
||||
for {
|
||||
item <- backend.itemSearch.findItem(id, user.account.collective)
|
||||
|
Reference in New Issue
Block a user