Specificly search for field id vs name

This commit is contained in:
Eike Kettner
2021-03-02 21:09:31 +01:00
parent b4b5acde13
commit a48504debb
7 changed files with 33 additions and 6 deletions

View File

@ -103,6 +103,8 @@ object ItemQuery {
final case class CustomFieldMatch(name: String, op: Operator, value: String)
extends Expr
final case class CustomFieldIdMatch(id: String, op: Operator, value: String)
extends Expr
final case class Fulltext(query: String) extends Expr

View File

@ -56,5 +56,7 @@ object ExprUtil {
expr
case CustomFieldMatch(_, _, _) =>
expr
case CustomFieldIdMatch(_, _, _) =>
expr
}
}

View File

@ -2,7 +2,6 @@ package docspell.query.internal
import cats.parse.{Parser => P}
import docspell.query.ItemQuery.Expr.CustomFieldMatch
import docspell.query.ItemQuery._
object SimpleExprParser {
@ -62,7 +61,13 @@ object SimpleExprParser {
val customFieldExpr: P[Expr.CustomFieldMatch] =
(P.string("f:") *> BasicParser.identParser ~ op ~ BasicParser.singleString).map {
case ((name, op), value) =>
CustomFieldMatch(name, op, value)
Expr.CustomFieldMatch(name, op, value)
}
val customFieldIdExpr: P[Expr.CustomFieldIdMatch] =
(P.string("f.id:") *> BasicParser.identParser ~ op ~ BasicParser.singleString).map {
case ((name, op), value) =>
Expr.CustomFieldIdMatch(name, op, value)
}
val inboxExpr: P[Expr.InboxExpr] =
@ -81,6 +86,7 @@ object SimpleExprParser {
tagIdExpr,
tagExpr,
catExpr,
customFieldIdExpr,
customFieldExpr,
inboxExpr,
dirExpr