Refactor search to separate between a base query and user query

The `findBase` is adding only strictly required conditions. Everything
else comes from the user.
This commit is contained in:
Eike Kettner
2021-02-24 21:57:41 +01:00
parent c3cdec416c
commit 186014a1c6
7 changed files with 129 additions and 112 deletions

View File

@ -164,7 +164,7 @@ object OFulltext {
.flatMap(r => Stream.emits(r.results.map(_.itemId)))
.compile
.to(Set)
q = Query.empty(account).copy(itemIds = itemIds.some)
q = Query.empty(account).withCond(_.copy(itemIds = itemIds.some))
res <- store.transact(QItem.searchStats(q))
} yield res
}
@ -208,7 +208,7 @@ object OFulltext {
search <- itemSearch.findItems(0)(q, Batch.all)
fq = FtsQuery(
ftsQ.query,
q.account.collective,
q.fix.account.collective,
search.map(_.id).toSet,
Set.empty,
500,
@ -220,7 +220,7 @@ object OFulltext {
.flatMap(r => Stream.emits(r.results.map(_.itemId)))
.compile
.to(Set)
qnext = q.copy(itemIds = items.some)
qnext = q.withCond(_.copy(itemIds = items.some))
res <- store.transact(QItem.searchStats(qnext))
} yield res
@ -253,7 +253,7 @@ object OFulltext {
val sqlResult = search(q, batch)
val fq = FtsQuery(
ftsQ.query,
q.account.collective,
q.fix.account.collective,
Set.empty,
Set.empty,
0,

View File

@ -138,7 +138,9 @@ object OItemSearch {
val search = QItem.findItems(q, maxNoteLen: Int, batch)
store
.transact(
QItem.findItemsWithTags(q.account.collective, search).take(batch.limit.toLong)
QItem
.findItemsWithTags(q.fix.account.collective, search)
.take(batch.limit.toLong)
)
.compile
.toVector