Turns Solr queries into Clojure predicates.
It's probably nothing interesting for you, really!
And it's also half-bake.
Take a look only if you want to see an usage of Christophe Grand's parser: parsley.
It takes a Solr query, and output a Clojure predicate that takes an object and return true if it matches the query.
In your project.clj
, in the dependency key, add this:
[solr-parse 0.1.0-SNAPSHOT]
Then
lein deps
Then you're good
The idea is to be able to compute, given a function and a solr query, a clojure function able to query a clj data store.
For example, given a function 'default-transco' which takes 2 parameters and returns a list of data:
(fact
(default-transco :a "b")
=> '(= (m :a) "b"))
And a query:
(fact
(compile-query default-transco "(a:b AND c:\"d\") OR (e:f) OR g:h")
=> '(or (and (= (m :a) :b) (= (m :c) "d")) (= (m :e) :f) (= (m :g) :h)))
Here is another function reverse-transco
:
(fact
(reverse-transco :a "b")
=> '(= (m "b") :a))
And the same query:
(fact
(compile-query reverse-transco "(a:b AND c:\"d\") OR (e:f) OR g:h")
=> '(or (and (= (m :b) :a) (= (m "d") :c)) (= (m :f) :e) (= (m :h) :g)))
In this example:
a:b
,c:"d"
,e:f
, andg:h
are some key value pair which hold meaning in your context.- m represents something in your
default-transco
orreverse-transco
Copyright © 2012 commiters
Distributed under the Eclipse Public License, the same as Clojure.