Best practice to create index with common and specific sets of properties per document

Hey guys, can you share the best practices how to create an index to achieve the following structure:

  • each document has a common set of properties (type, priority, status)
  • each document has a specific set of properties (depending on type)

The main criteria is a performance.
elasticsearch v6.7

I have a couple of ideas listed below:

approach#1

{
  "settings": {
    "index": {
      "number_of_shards": "6",
      "number_of_replicas": "2"
    }
  },
  "mappings": {
    "event": {
      "properties": {
        "type": {
          "type": "keyword"
        },
        "priority": {
          "type": "keyword"
        },
        "status": {
          "type": "keyword"
        },
        "eventType#1Details": {
          "type": "nested",
          "properties": {
            "eventType#1Detail#1": {
              "type": "boolean"
            },
            "eventType#1Detail#2": {
              "type": "long"
            },
            "eventType#1Detail#3": {
              "type": "keyword"
            }
          }
        },
        "eventType#2Details": {
          "type": "nested",
          "properties": {
            "eventType#2Detail#1": {
              "type": "long"
            },
            "eventType#2Detail#2": {
              "type": "keyword"
            }
          }
        },
        "eventType#3Details": {
          "type": "nested",
          "properties": {
            "eventType#3Detail#1": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
}

approach#2

    {
      "settings": {
        "index": {
          "number_of_shards": "6",
          "number_of_replicas": "2"
        }
      },
      "mappings": {
        "event": {
          "properties": {
            "type": {
              "type": "keyword"
            },
            "priority": {
              "type": "keyword"
            },
            "status": {
              "type": "keyword"
            },
            "details": {
              "type": "nested",
              "properties": {
                "eventType#1Detail#1": {
                  "type": "boolean"
                },
                "eventType#1Detail#2": {
                  "type": "long"
                },
                "eventType#1Detail#3": {
                  "type": "keyword"
                },
                "eventType#2Detail#1": {
                  "type": "long"
                },
                "eventType#2Detail#2": {
                  "type": "keyword"
                },
                "eventType#3Detail#1": {
                  "type": "keyword"
                }
              }
            }
          }
        }
      }
    }

approach#3

{
  "settings": {
    "index": {
      "number_of_shards": "6",
      "number_of_replicas": "2"
    }
  },
  "mappings": {
    "event": {
      "properties": {
        "type": {
          "type": "keyword"
        },
        "priority": {
          "type": "keyword"
        },
        "status": {
          "type": "keyword"
        },
        "eventType#1Detail#1": {
          "type": "boolean"
        },
        "eventType#1Detail#2": {
          "type": "long"
        },
        "eventType#1Detail#3": {
          "type": "keyword"
        },
        "eventType#2Detail#1": {
          "type": "long"
        },
        "eventType#2Detail#2": {
          "type": "keyword"
        },
        "eventType#3Detail#1": {
          "type": "keyword"
        }
      }
    }
  }
}

Thanks in advance.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.