Hey all,

Relatively new to Clojure, and I'm wondering if there is a better/simpler 
way to handle what I'm doing.

I'm working with the Elastisch library for interacting with ElasticSearch, 
and it has the following function:
http://reference.clojureelasticsearch.info/clojurewerkz.elastisch.rest.document.html#var-search

(search index mapping-type & {:as options})

That's all fine, except I want to call it from another function, to provide 
my default values for `index`, but still allow for the passthrough the 
options map for the `search` function.

The solution I came up with was:

(defn search
"Search the mapping-type, with the given properties"
[mapping-type & {:as options}]
(apply esd/search (reduce (fn [coll [k, v]] (conj coll k v)) [es-index 
mapping-type] options)))

Where `es-index` is already defined as a global def.

So basically I break the options apart into a vector, and apply it over the 
top of the esd/search function (where esd is the elastisch function defined 
earlier).

Does this make sense? Is there a better way?

It works, but wondering if there is an improvement I could make, especially 
as I could see myself doing this quite often.

Thanks in advance,

Mark


-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to