kuzzle-admin-console icon indicating copy to clipboard operation
kuzzle-admin-console copied to clipboard

Impossible to add dynamic template when creating a collection

Open Tyki opened this issue 5 years ago • 3 comments

It's impossible to create a collection with a dynamic template via the admin console

Expected Behavior

Have the posssibility to add dynamic_template through admin console

Current Behavior

An error is raised when creating a collection with dynamic_template entry in the payload

Possible Solution

Steps to Reproduce

  1. Gist : https://gist.github.com/Tyki/6763f4661bb9b10ab6f1c1ca37ff843a
  2. Try to create a collection with this mapping
  3. Constat the error image
  4. The same mapping directly sent to curl http://localhost:9200/app-at-dev/_mapping/UserJournalAction -XPUT -d "@mapping.json" is working fine

Context (Environment)

Kuzzle version: 1.11 Node.js version: 10 Admin Console Version: 2.5.3

Tyki avatar Nov 27 '19 10:11 Tyki

Hello @Tyki,

It's an issue caused by the way we are sending the mapping through the Admin Console. We send everything declared within the form inside the properties field of mappings.
So it end up like this:

{
  properties: {
    dynamic_templates: ...,
    properties: ...
  }
}

In the meantime you can use the SDK to create your collection, see this Gist

Aschen avatar Nov 28 '19 03:11 Aschen

I have just encountered this myself when experimenting with Kuzzle and the Admin Console. The text in the "Update " wizard is:

Mapping is the process of defining how a document, and the fields it contains, are stored and indexed. Read more about mapping You should omit the root "properties" field in this form.

{
  "age": { "type": "integer" },
  "name": { "type": "text" }
}

I think an easy fix for this would be to simply change this textarea to accept the complete mapping policy as per the docs [1] . I am happy to submit a PR for this if the maintainers think it is suitable UX. If not, please could you explain why this textarea is designed to only accept the properties key (through the implicit nesting)?

Thanks! :smile:

[1] https://docs.kuzzle.io/core/2/guides/essentials/database-mappings/

wcerfgba avatar Nov 27 '20 23:11 wcerfgba

Hello @wcerfgba your remark is completely legitimate, but I'm not sure about the idea of accepting the whole ES-index definition in the JSON textarea. Currently, the dynamic property, which is a sibling of properties in the index definition, is taken in the UI by a radio button so, if we make the textarea accept the whole definition, we should take the radio button away and let the user define the dynamic property in the JSON, which consists, IMHO, in giving up the explicit help the UI provides on this feature (by showing the allowed values and a short help text).

My suggestion would be (and please, let me know your thoughts on it) to put the JSON textarea in a tabs navigator, which would have 2 tabs: "Properties" and "Templates". Both would contain their own JSON textarea and their own cheatsheet helping the user figuring out what it's for. What do you think? Of course, if you feel like proposing an implementation, go ahead! Thanks a lot!

xbill82 avatar Dec 07 '20 13:12 xbill82