我正在尝试 clojure 弹性搜索 API Elastisch。
我正在关注文档中给出的演示代码,我正在为以下代码获取文档/索引创建的输出
(defn demo-search-connect []
(esr/connect! "http://127.0.0.1:9200")
(let [mapping-types {:person {:properties {:username {:type "string" :store "yes"}
:first-name {:type "string" :store "yes"}
:last-name {:type "string"}
:age {:type "integer"}
:title {:type "string" :analyzer
"snowball"}
:planet {:type "string"}
:biography {:type "string" :analyzer "snowball" :term_vector "with_positions_offsets"}}}}
doc {:username "happyjoe" :first-name "Joe" :last-name "Smith" :age 30 :title "Teh Boss" :planet "Earth" :biography "N/A"}]
(esi/create "myapp2_development" :mappings mapping-types)
;; adds a document to the index, id is automatically generated by ElasticSearch
;= {:ok true, :_index people, :_type person, :_id "2vr8sP-LTRWhSKOxyWOi_Q", :_version 1}
(println (esd/create "myapp2_development" :person doc :settings {"number_of_shards" 1}))
))
;Supposed to return an output for the search query
(defn demo-search-index []
(esr/connect! "http://127.0.0.1:9200")
(esd/search "myapp2_development" "person" :query {:term {:last_name "Smith"}})
)
;Supposed to return the document with the given id
(defn get-document [id]
(esr/connect! "http://127.0.0.1:9200")
(esd/get "myapp2_development" "person" id)
)
我得到的第一个函数的输出为:
{:ok true, :_index myapp2_development, :_type :person, :_id GzNdzrqhQECQDlkSbq-GHA, :_version 1}
从输出中,我相信该文档已正确编入索引
问题是第二个和第三个函数返回:
{:took 153, :timed_out false, :_shards {:total 5, :successful 5, :failed 0}, :hits {:total 0, :max_score nil, :hits []}}
和nil
分别。
我在这里想念什么?
PS:我是clojure和弹性搜索的新手