Permalink
Browse files

Committing working code before I fuck it up for tomorrow.

  • Loading branch information...
1 parent 19c6ce9 commit 8a760b3c68ae87c9bd3523c06be46dd4b69b106a @rdrake committed Mar 27, 2012
Showing with 28 additions and 31 deletions.
  1. +0 −2 src/molly/core.clj
  2. +2 −2 src/molly/datatypes/entity.clj
  3. +26 −27 src/molly/server/serve.clj
View
@@ -15,10 +15,8 @@
(defn -main
[& args]
- (println "args")
(let [[opts arguments banner] (parse-args (flatten args))
action (opts :action)]
- (println "if")
(if (= action "serve")
((println "Starting Molly...")
(start!))
@@ -51,7 +51,7 @@
[C
(first attr-cols)])))
:entity (assoc meta-data :id (uid this C id-col))
- :group meta-data
+ :group (assoc meta-data :entities (uid this id-col))
(throw (IllegalArgumentException. "I only know how to deal with types :value, :entity, and :group"))))))
(defn doc->data
@@ -83,5 +83,5 @@
(condp = (int-meta :type)
:value []
:entity [[:__id__ (int-meta :id)]]
- :group [[:entities (int-meta :entities)]]))]
+ :group []))];[[:entities (int-meta :entities)]]))]
(document raw-doc)))
View
@@ -7,36 +7,35 @@
(:require [noir.server :as server]
[noir.response :as response]))
-(def searcher (idx-searcher (idx-path "mycampus.idx")))
-
-(defn dox
- [q1 field S]
- (let [bq (boolean-query
- (concat [[q1 :and]]
- (for [s S]
- [(query field s) :or])))]
- (map doc->data (idx-search searcher bq))))
+(defn start!
+ []
+ (let [searcher (idx-searcher (idx-path "mycampus.idx"))]
+ (defn dox
+ [q1 field S op]
+ (let [bq (boolean-query
+ (concat [[q1 :and]]
+ (for [s S]
+ [(query field s) op])))]
+ (map doc->data (idx-search searcher bq)))))
-(defpage "/" []
- (response/redirect "/index.html"))
+ (defpage "/" []
+ (response/redirect "/index.html"))
-(defpage "/suggest/:q" {:keys [q]}
- (response/json
- (dox (query :type :value)
- :text
- (clojure.string/split (q-gram q) #"\s{1}"))))
+ (defpage "/suggest/:q" {:keys [q]}
+ (response/json
+ (dox (query :type :value)
+ :text
+ (clojure.string/split (q-gram q) #"\s{1}") :or)))
-(defpage "/entity/:q" {:keys [q]}
- (response/json
- (dox (query :type :entity)
- :text
- (clojure.string/split q #"\s{1}"))))
+ (defpage "/entity/:q" {:keys [q]}
+ (response/json
+ (dox (query :type :entity)
+ :text
+ (clojure.string/split q #"\s{1}") :or)))
-(defpage "/group/:q" {:keys [q]}
- (println q)
- (response/json
- (dox (query :type :group) :entity [q])))
+ (defpage "/group/:q" {:keys [q]}
+ (println q)
+ (response/json
+ (dox (query :type :group) :entities [q] :and)))
-(defn start!
- []
(server/start 8080))

0 comments on commit 8a760b3

Please sign in to comment.