(defn search-hit->elastisch-document
"When you do a search in Elastisch, a single 'hit' in the search result might look like:
{:_index \".kibana\" :_type \"search\" :_id \"Foo\" ... _source {:columns ... :description ...}}
Where the first '...' is the ES document metadata, and the '...' in the _source maps is the various
properties of the document.
If you want to take the above hit and use it to create a document though,
if you pass that into the (esb/bulk-create ...) interface it will correctly pick off the
ES metaproperties, but not the _source stuff. Elastisch wants ALL the properties in at the same
level in a map. E.g.
{:_index \".kibana\" :_type \"search\" :_id \"Foo\" ... :columns ... :description ...}
So this function does that transformation. If there's such a function in Elastisch I haven't found it.
Elastisch doesn't even have a test coded for bulk-create much less the sort of search-hit->doc-action
I'm talking about.
FURTHERMORE: It looks like Elastisch doesn't support 'create' operations at all.
Looking at cnv/->action-requests and the AddOperation protocols, there's no 'create' support.
Use 'index. E.g. (esb/bulk conn (esb/bulk-index ...docs...)), not bulk-create.
Input: search hit or similar map.
Output: suitably flattened map."
[search-hit]
;; *TBD*: DO I need to remove everything but _id _type _index w.r.t. ES meta properties?
;; e.g. remove :_score? For now I am. That includes _score, _version, :highlight (Elastisch meta?),
;; and maybe other things like aggregates or what have you.
(assoc (:_source search-hit)
:_id (:_id search-hit)
:_type (:_type search-hit)
:_index (:_index search-hit)))