json-schema-org / json-schema-vocabularies

Experimental vocabularies under consideration for standardization
53 stars 9 forks source link

Working with Elasticsearch Mappings #44

Open eric-kolotyluk opened 2 years ago

eric-kolotyluk commented 2 years ago

I apologize if this is not the appropriate forum for these questions, so please direct me to the appropriate place if necessary...

We are in the process of adopting JSON Schema, and we are heavy users of Elasticsearch. One of the ideas we are considering is using JSON Schema to define our entities in Elasticsearch in such as way that we can automatically generate the Elasticsearch Mapping from the JSON Schema, such that JSON Schema is always (as much as possible) our core schema mechanism.

Would it be appropriate to use different dialects and vocabularies that define keywords and such in support of guiding the Elasticsearch Mapping generation. For example, by default we generally want to define 'keyword' data instead of the default 'text' data; but in some cases we might want to override the defaults in our JSON Schema with an 'elasticsearch' keyword, for example

  "properties": {
    "explanation": {
      "description": "a natural language explanation/justification",
      "type": "string",
      "elasticsearch": {
        "fieldDataType": "text",
        "$comment": "override 'keyword' default"
      }
    }
  }

Am I making sense, or out to lunch? Am I understanding the intent of JSON Schema Vocabularies?

handrews commented 2 years ago

Yes, this is exactly what they are for! Keyword design can be a bit of a tricky topic, so I recommend looking through the slides (and reading the presentation notes - don't forget to scroll to make sure you see all of the notes) linked in the Keyword Behaviors / JSON Schema as a Framework (JSF) discussion. Feel free to comment in general there, or to ask specific questions about your situation here.

eric-kolotyluk commented 2 years ago

Phew, thanks. 🙄

While I have been using JSON Schema for years, I have never used such advanced features, and given I am the reason we are adopting JSON Schema, I don't want to make too many mistakes here.