# "Unknown key for a START\_ARRAY in in json

**URL:** <https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091>\
**Category:** Elasticsearch\
**Created:** [April 28, 2020, 7:18am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091 "2020-04-28T07:18:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinay123](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vinay123](https://discuss.elastic.co/u/vinay123)\
**Post date:** [April 28, 2020, 7:18am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/1 "2020-04-28T07:18:45Z")

</div>

Hello Team ,  
i have a large json file which has nested kind of, the start of json file has array. when i a writing a search query i am getting error as _ **Unknown key for a START\_ARRAY** _

parsing issue.

any suggestions to solve this

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 28, 2020, 7:30am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/2 "2020-04-28T07:30:33Z")

</div>

It indicates most likely a wrong json.  
Hard to tell more without an example.

---

<div class="post-metadata">

**Author:** ![vinay123](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vinay123](https://discuss.elastic.co/u/vinay123)\
**Post date:** [April 28, 2020, 7:39am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/4 "2020-04-28T07:39:45Z")

</div>

> [@dadoonet](#):
>
> It indicates most likely a wrong json.  
> Hard to tell more without an example.

This is sample json format looks like as below

{  
"test": [  
{

```
" name":" vinay",
"location":"india"

},
{
  "name":"kumar",
  "location":"india2",
  "contactdetails":[
    {
      "phone":"1234",
      "address":"hyd"
    }
    ]
}

```

]  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 28, 2020, 8:02am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/5 "2020-04-28T08:02:10Z")

</div>

This works well:

```auto
DELETE test 
POST test/_doc
{
  "test": [
    {
      " name": " vinay",
      "location": "india"
    },
    {
      "name": "kumar",
      "location": "india2",
      "contactdetails": [
        {
          "phone": "1234",
          "address": "hyd"
        }
      ]
    }
  ]
}

```

It gives:

```auto
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "bVTOv3EBJjDNjw2CIKRe",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

```

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![vinay123](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vinay123](https://discuss.elastic.co/u/vinay123)\
**Post date:** [April 28, 2020, 8:11am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/6 "2020-04-28T08:11:52Z")

</div>

It worked..Thanks for help..

---

<div class="post-metadata">

**Author:** ![vinay123](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vinay123](https://discuss.elastic.co/u/vinay123)\
**Post date:** [April 28, 2020, 8:17am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/7 "2020-04-28T08:17:26Z")

</div>

> [@dadoonet](#):
>
> { "test": [{ " name": " vinay", "location": "india" }, { "name": "kumar", "location": "india2", "contactdetails": [{ "phone": "1234", "address": "hyd" }] } ] }

on this json ia trying to write a match query based on filed, but i am not getting results..

query :  
{  
"query": {  
"bool": {  
"must": [  
{ "match": { "name": "kumar" }},  
{ "match": { "location": "india2" }}  
]  
}  
}  
}  
expected output :  
{  
"name": "kumar",  
"location": "india2",  
"contactdetails": [  
{  
"phone": "1234",  
"address": "hyd"  
}  
]  
}

is it possible ? because i have everything on one document

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 28, 2020, 10:11am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/8 "2020-04-28T10:11:52Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 28, 2020, 10:12am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/9 "2020-04-28T10:12:55Z")

</div>

> [@vinay123](#):
>
> is it possible ?

Yeah. May be with the `nested` document feature. But the question is more: why are you putting all that in the same document?

---

<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:** [May 26, 2020, 10:12am UTC](https://discuss.elastic.co/t/unknown-key-for-a-start-array-in-in-json/230091/10 "2020-05-26T10:12:56Z")

</div>

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