Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index creation - :settings requires string keys, but docs suggest keywords. #70

Closed
aphyr opened this issue Feb 4, 2014 · 5 comments
Closed

Comments

@aphyr
Copy link

aphyr commented Feb 4, 2014

elastisch.native.index/create works fine with string keys:

 (esi/create index-name
              :mappings mapping-types
              :settings {"index" {"refresh_interval"  "30s"
                                  "warmer"            {"enabled" "false"}}}))

But the docs suggest using keywords, like so:

  (esi/create index-name
              :mappings mapping-types
              :settings {:index {:refresh_interval  "30s"
                                 :warmer            {:enabled false}}}))

Which throws ClassCastException from native.conversion/->create-index-request

ClassCastException clojure.lang.Keyword cannot be cast to java.lang.String
    org.elasticsearch.common.xcontent.XContentBuilder.writeMap (XContentBuilder.java:1095)
    org.elasticsearch.common.xcontent.XContentBuilder.map (XContentBuilder.java:1015)
    org.elasticsearch.action.admin.indices.create.CreateIndexRequest.settings (CreateIndexRequest.java:175)
    clojurewerkz.elastisch.native.conversion/->create-index-request (conversion.clj:758)
    clojurewerkz.elastisch.native.index/create (index.clj:53)
    gauntlet.elasticsearch/setup-es! (elasticsearch.clj:82)
    gauntlet.elasticsearch/bench!/fn--4961 (elasticsearch.clj:116)
    gauntlet.elasticsearch/bench! (elasticsearch.clj:116)
    user/eval4978 (form-init109469628037641998.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:6619)
    clojure.lang.Compiler.eval (Compiler.java:6582)
    clojure.core/eval (core.clj:2852)

Incorrect docs? Should we change the code?

@michaelklishin
Copy link
Member

This is because the docs were effectively ported from the HTTP client. AFAIR The Daily Mail folks contributed some performance improvements that involved giving up on clojure.walk/stringify-keys in some places in the native client.

I'd say lets use strings everywhere in the docs. There is no real upside to using keywords. Feel free to submit a pull request.

@michaelklishin
Copy link
Member

Another point: HTTP client eventually delegates to clj-http which assumes maps can have keyword keys. ES native client expects string keys.

@aphyr
Copy link
Author

aphyr commented Feb 4, 2014

Know a leaky abstraction. Where are the docs? Trying to figure out where to make a PR to.

@aphyr
Copy link
Author

aphyr commented Feb 4, 2014

Aha! Another repo. https://github.com/clojurewerkz/elastisch.docs

@aphyr
Copy link
Author

aphyr commented Feb 4, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants