我正在尝试使用clojure和neocons库将数据从StackOverflow导入Neo4j.请原谅我是一个新手.
这是我在Leiningen的主要功能:
(defn -main
[& args]
(let [neo4j-conn (nr/connect "http://localhost:7777/db/data/")]
(cypher/tquery neo4j-conn "MATCH n OPTIONAL MATCH n-[r]-() DELETE n, r")
(for [page (range 1 6)]
(let [data (parse-string (stackoverflow-get-questions page))
questions (data "items")
has-more (data "has_more")
question-ids (map #(%1 "question_id") questions)
answers ((parse-string (stackoverflow-get-answers question-ids)) "items")]
(map #(import-question %1 neo4j-conn) questions)
(map #(import-answer %1 neo4j-conn) answers)
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
我已经定义import-question和import-answer功能,这些工作独立.事实上,奇怪的是我可以删除其中任何一条import-*线,而另一条线条可以正常工作.
任何人都可以看到我做的事情是不是很简单?