# Schema Defination

**URL:** <https://discuss.elastic.co/t/schema-defination/35933>\
**Category:** Elasticsearch\
**Created:** [November 30, 2015, 5:46pm UTC](https://discuss.elastic.co/t/schema-defination/35933 "2015-11-30T17:46:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sivaprakash\_Shanmuga](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Sivaprakash\_Shanmuga](https://discuss.elastic.co/u/Sivaprakash_Shanmuga)\
**Post date:** [November 30, 2015, 5:46pm UTC](https://discuss.elastic.co/t/schema-defination/35933/1 "2015-11-30T17:46:53Z")

</div>

Hi

Im trying to crate schema for below data structure

> {  
> "student" : {  
> "name" : "John",  
> "subject" : [1957, 1952]  
> }  
> }

In this, subject has to take array of values, I have defined my schema as

> {  
> "student" : {  
> "properties" : {  
> "name" : {"type" : "string"},   
> "lists" : {  
> "properties" : {  
> "subject" : {"type" : "string"}  
> }  
> }  
> }  
> }  
> }

Is it a right structure ?

---

<div class="post-metadata">

**Author:** ![vtst2412](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vtst2412/32/6228_2.png) [@vtst2412](https://discuss.elastic.co/u/vtst2412)\
**Post date:** [November 30, 2015, 6:06pm UTC](https://discuss.elastic.co/t/schema-defination/35933/2 "2015-11-30T18:06:23Z")

</div>

Looks almost like you're looking for the mapping of this "schema". How about:

```
{
  "mappings": {
    "type1": {
      "properties": {
        "student": {
          "type": "nested"
          "properties": {
            "name" :{
                "type": "string"
            }
            "subject": {
                "type" : "array"
            }
          }
        }
      }
    }
  }
}

```

The field `student` can be either nested or object. Read more about nested object here to see if it fits your use case.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html)

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 30, 2015, 6:07pm UTC](https://discuss.elastic.co/t/schema-defination/35933/3 "2015-11-30T18:07:23Z")

</div>

What does `lists` come from? Also, the elements of the `subject` array are integers, not strings. This should be better:

```auto
{
  "student" : {
    "properties" : {
      "name" : {"type" : "string"},	
      "subject" : {"type" : "integer"}
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:34pm UTC](https://discuss.elastic.co/t/schema-defination/35933/4 "2017-07-05T23:34:46Z")

</div>

Closed on July 5, 2017, 11:34pm UTC


