SQL commands from Tutorial - SQL command skips "type"

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}

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

You should BTW use _doc as the type name.

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?


@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" }

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:


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

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.


"doc": {

And its matching }

@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.

@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" }

PUT twitter/_doc/tweet-1
{ "type": "tweet", "user_name": "kimchy", "tweeted_at": "2017-10-24T09:00:00Z"}
ES-custom-type Preformatted text


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

PUT /library/_bulk?refresh


PUT /library/_doc/_bulk?refresh

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