# SQL commands from Tutorial - SQL command skips "type"

**URL:** <https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582>\
**Category:** Elasticsearch\
**Created:** [March 22, 2020, 11:52pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582 "2020-03-22T23:52:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![debasisc](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@debasisc](https://discuss.elastic.co/u/debasisc)\
**Post date:** [March 22, 2020, 11:52pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/1 "2020-03-22T23:52:15Z")

</div>

Although we mention Index (library) and type (book) when inserting records, SQL query only mentions index name. Can you please explain this? Thank you

# POST /\_sql?format=txt { "query": "SELECT \* FROM library WHERE release\_date \< '2000-01-01'" }

PUT /library/book/\_bulk?refresh

{"index":{"\_id": "Leviathan Wakes"}}

{"name": "Leviathan Wakes", "author": "James S.A. Corey", "release\_date": "2011-06-02", "page\_count": 561}

{"index":{"\_id": "Hyperion"}}

{"name": "Hyperion", "author": "Dan Simmons", "release\_date": "1989-05-26", "page\_count": 482}

{"index":{"\_id": "Dune"}}

{"name": "Dune", "author": "Frank Herbert", "release\_date": "1965-06-01", "page\_count": 604}

---

<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:** [March 23, 2020, 4:41am UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/2 "2020-03-23T04:41:16Z")

</div>

Types are going to be removed. See [https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch](https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch)

You should BTW use `_doc` as the type name.

---

<div class="post-metadata">

**Author:** ![debasisc](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@debasisc](https://discuss.elastic.co/u/debasisc)\
**Post date:** [March 23, 2020, 12:30pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/3 "2020-03-23T12:30:35Z")

</div>

Thanks @dadoonet.

Are you suggesting that the PUT command should be modified as  
PUT /library/\_doc/\_bulk?refresh  
instead of  
PUT /library/book/\_bulk?refresh ?

Will the tutorial pages be revised at some point of time suitably?

[https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-getting-started.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-getting-started.html)

---

<div class="post-metadata">

**Author:** ![debasisc](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@debasisc](https://discuss.elastic.co/u/debasisc)\
**Post date:** [March 23, 2020, 1:15pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/4 "2020-03-23T13:15:46Z")

</div>

@dadoonet - Following your thread (very useful, by the way. Thank you), I tried the example below for custom type inside single index. This gives error, by the way. I am using version 7.5.2 in Windows 10. Can you please check and advise? Thanks

PUT twitter  
{  
"mappings": {  
"doc": {  
"properties": {  
"type": { "type": "keyword" },  
"name": { "type": "text" },  
"user\_name": { "type": "keyword" },  
"email": { "type": "keyword" },  
"content": { "type": "text" },  
"tweeted\_at": { "type": "date" }  
}  
}  
}  
}

---

<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:** [March 23, 2020, 1:27pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/5 "2020-03-23T13:27:51Z")

</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.  
Please update your post.

---

<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:** [March 23, 2020, 1:28pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/6 "2020-03-23T13:28:43Z")

</div>

Remove:

```
"doc": {

```

And its matching `}`

---

<div class="post-metadata">

**Author:** ![debasisc](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@debasisc](https://discuss.elastic.co/u/debasisc)\
**Post date:** [March 23, 2020, 1:36pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/7 "2020-03-23T13:36:35Z")

</div>

@dadoonet - Thanks. Custom type now works after I remove "doc" and matching curly bracket.

So, the pending question is about the original SQL command. What should be revised command?  
PUT /library/book/\_bulk?refresh

And are there plans to revise tutorials with correct working examples?  
Thanks again for your help.

---

<div class="post-metadata">

**Author:** ![debasisc](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@debasisc](https://discuss.elastic.co/u/debasisc)\
**Post date:** [March 23, 2020, 1:44pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/8 "2020-03-23T13:44:00Z")

</div>

@dadoonet - Also should I mention \_doc in the following commands for custom types inside single index? The tutorial in elastic website shows "doc" rathher than "\_doc".

PUT twitter/\_doc/user-kimchy  
{ "type": "user", "name": "Shay Banon", "user\_name": "kimchy", "email": "[shay@kimchy.com](mailto:shay@kimchy.com)" }

PUT twitter/\_doc/tweet-1  
{ "type": "tweet", "user\_name": "kimchy", "tweeted\_at": "2017-10-24T09:00:00Z"}  
 ![ES-custom-type](https://us1.discourse-cdn.com/elastic/original/3X/2/d/2dec2a486d99e1df30aa878ed68456d5937e1e71.png) `Preformatted text`

---

<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 3, 2020, 4:26pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/9 "2020-04-03T16:26:26Z")

</div>

> [@debasisc](#):
>
> So, the pending question is about the original SQL command. What should be revised command?  
> PUT /library/book/\_bulk?refresh

Probably:

So, the pending question is about the original SQL command. What should be revised command?

```
PUT /library/_bulk?refresh

```

Or:

```
PUT /library/_doc/_bulk?refresh

```

---

<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 1, 2020, 4:26pm UTC](https://discuss.elastic.co/t/sql-commands-from-tutorial-sql-command-skips-type/224582/10 "2020-05-01T16:26:28Z")

</div>

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