# Types for JSON file using bulk API

**URL:** <https://discuss.elastic.co/t/types-for-json-file-using-bulk-api/118474>\
**Category:** Elasticsearch\
**Created:** [February 5, 2018, 2:34pm UTC](https://discuss.elastic.co/t/types-for-json-file-using-bulk-api/118474 "2018-02-05T14:34:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomak](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tomak](https://discuss.elastic.co/u/tomak)\
**Post date:** [February 5, 2018, 2:34pm UTC](https://discuss.elastic.co/t/types-for-json-file-using-bulk-api/118474/1 "2018-02-05T14:34:15Z")

</div>

I would like to add a JSON file with a lot of lines like this.

```
{"index":{"_index": "fake", "_type": "keyword", "_id":"2"}}
{"info":"2", "bob":3}

```

Is there a way of defining the type and index once and for all for a JSON file (because it will be the same thing for each line)

I was wondering also what the different types were?

I know integer and keyword. Is there a type for "indentation"?

Like if I would have my JSON file like this:

`"_id":{"$oid":"52287a4ee4b07193f703c23f"}}`

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [February 5, 2018, 2:37pm UTC](https://discuss.elastic.co/t/types-for-json-file-using-bulk-api/118474/2 "2018-02-05T14:37:11Z")

</div>

Like I mentioned in my [previous answer](https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-bulk-api/118465/6), you can remove the index and type information from your JSON file like this:

```
{"index":{"_id":"2"}}
{"info":"2", "bob":3}

```

and then add those to your curl command

```
curl -XPOST -H 'Content-Type: application/json' localhost:9200/fake/type/_bulk --data-binary @/path/to/your/file.json

```

Also note that the type information has nothing to do with your field types (keyword, integer, etc), but it is a [mapping type](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html), i.e. the place where you define all your index fields

Finally, the `_id` can only take literal value, but not an object value. You could hash `{"$oid":"52287a4ee4b07193f703c23f"}` into some string and use that string as ID, though

---

<div class="post-metadata">

**Author:** ![tomak](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tomak](https://discuss.elastic.co/u/tomak)\
**Post date:** [February 5, 2018, 3:40pm UTC](https://discuss.elastic.co/t/types-for-json-file-using-bulk-api/118474/3 "2018-02-05T15:40:11Z")

</div>

Sorry I didn't pay attention and didn't see the "type" in your curl.

---

<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:** [March 5, 2018, 3:40pm UTC](https://discuss.elastic.co/t/types-for-json-file-using-bulk-api/118474/4 "2018-03-05T15:40:55Z")

</div>

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