1
0
Fork 0

- added more terms when searching gempub metadata ('<', '>', '<=', '<=', '=' '!=').

This commit is contained in:
cage 2021-08-28 14:20:34 +02:00
parent baf3f4c1ea
commit e763158a8b
1 changed files with 55 additions and 2 deletions

View File

@ -127,12 +127,23 @@
(defrule spaces (+ blank)
(:constant nil))
(defrule column (or "title"
(defrule publish-date-alias "publishedDate"
(:constant "\"published-date\""))
(defrule revision-date-alias "revisionDate"
(:constant "\"revision-date\""))
(defrule column-alias (or publish-date-alias
revision-date-alias))
(defrule column (or column-alias
"title"
"author"
"language"
"description"
"publish-date"
"revision-date"
"published"
"copyright")
(:text t))
@ -141,7 +152,13 @@
(defrule term (or and-where
or-where
like)
like
=-term
!=-term
<-term
>-term
<=-term
>=-term)
(:function (lambda (a) (join-with-strings a " "))))
(defrule like (and column spaces "like" spaces column-value)
@ -150,6 +167,42 @@
(first a)
(string-trim '(#\") (fifth a))))))
(defrule =-term (and column spaces "=" spaces column-value)
(:function (lambda (a) (format nil
"~a = ~a"
(first a)
(fifth a)))))
(defrule <-term (and column spaces "<" spaces column-value)
(:function (lambda (a) (format nil
"~a < ~a"
(first a)
(fifth a)))))
(defrule >-term (and column spaces ">" spaces column-value)
(:function (lambda (a) (format nil
"~a > ~a"
(first a)
(fifth a)))))
(defrule <=-term (and column spaces "<=" spaces column-value)
(:function (lambda (a) (format nil
"~a <= ~a"
(first a)
(fifth a)))))
(defrule >=-term (and column spaces ">=" spaces column-value)
(:function (lambda (a) (format nil
"~a >= ~a"
(first a)
(fifth a)))))
(defrule !=-term (and column spaces "!=" spaces column-value)
(:function (lambda (a) (format nil
"~a != ~a"
(first a)
(fifth a)))))
(defrule and-where (and term spaces "and" spaces term))
(defrule or-where (and term spaces "or" spaces term))