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}
出力から、ドキュメントは適切にインデックス化されていると思います
問題は、2 番目と 3 番目の関数が次を返すことです。
{:took 153, :timed_out false, :_shards {:total 5, :successful 5, :failed 0}, :hits {:total 0, :max_score nil, :hits []}}
そしてnil
それぞれ。
ここで何が欠けていますか?
PS:私はクロージュアとエラスティック検索が初めてです