# Differences in PUT requests in ES versions

**URL:** <https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171>\
**Category:** Elasticsearch\
**Created:** [January 23, 2022, 11:59pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171 "2022-01-23T23:59:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![EnJay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enjay/32/100715_2.png) [@EnJay](https://discuss.elastic.co/u/EnJay)\
**Post date:** [January 23, 2022, 11:59pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/1 "2022-01-23T23:59:53Z")

</div>

Hello everyone 🐥  
I actively study Elasticsearch.  
I had to update my version ES to the latest from 5. But here I ran into a problem, the answer to which I could not find in the documentation.

I used ES 5 version, when adding new information for example to this sections:

```auto
PUT /coin_charts/btc/1
PUT /coin_charts/eth/1
PUT /coin_charts/ada/1

```

It automatically created the structure and information was added.

But in the new version, when trying to do the same, it gives an error:

```auto
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Invalid type: expecting [btc] but got [eth]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Invalid type: expecting [btc] but got [eth]"
    },
    "status": 400

```

How can this be corrected? Please tell a newbie 🙂

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 24, 2022, 12:03am UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/2 "2022-01-24T00:03:09Z")

</div>

Please see [Removal of mapping types | Elasticsearch Guide [7.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/removal-of-types.html)

---

<div class="post-metadata">

**Author:** ![EnJay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enjay/32/100715_2.png) [@EnJay](https://discuss.elastic.co/u/EnJay)\
**Post date:** [January 24, 2022, 1:49am UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/3 "2022-01-24T01:49:33Z")

</div>

I'm not sure about information actuality here, but I use the first example and get an error 😟  
This request from tutorial:

 ![Снимок экрана 2022-01-24 в 03.48.04](https://us1.discourse-cdn.com/elastic/original/3X/2/c/2c331cf00f17501cc5463559e06621dae3a10604.png)

Response:

 ![Снимок экрана 2022-01-24 в 03.48.17](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a59cf507fff151cbb84f66059953e9fccfe33fde.jpeg)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 24, 2022, 2:01am UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/4 "2022-01-24T02:01:58Z")

</div>

> [@EnJay](#):
>
> I use the first example and get an error

Yes that's why it says "Originally, the workflow would have looked something like this" and then shows you how to do it now 🙂 That's what you need to adapt to.

---

<div class="post-metadata">

**Author:** ![EnJay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enjay/32/100715_2.png) [@EnJay](https://discuss.elastic.co/u/EnJay)\
**Post date:** [January 25, 2022, 7:41pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/5 "2022-01-25T19:41:46Z")

</div>

Sorry, my english level let me down 😅

But, i can't make this mappings already the second day...  
I can’t make the structure I need in any way, maybe I don’t understand something.  
I need to make stuctures like this:

```auto
/coin_charts/bitcoin/1
/coin_charts/bitcoin/2
/coin_charts/bitcoin/3

```

```auto
/coin_charts/ethereum/1
/coin_charts/ethereum/2
/coin_charts/ethereum/3

```

However, in each section(bitcoin, ethereum and 12 thousand others) structure should be the same:

```auto
{
      "priceUsd": 100,
      "time": 1643139643011
}

```

Could you help with creting mapping? I beg you, I can't deal with this ☹  
I will be very grateful for your help

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 25, 2022, 7:49pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/6 "2022-01-25T19:49:55Z")

</div>

Elasticsearch no longer supports specifying multiple document types for an index so I would recommend adding a field to each document that contains the type and use a default type (\_doc) as follows:

```auto
coin_charts/_doc/bitcoin-1

```

```auto
{
      "currency": "bitcoin",
      "priceUsd": 100,
      "time": 1643139643011
}

```

You can let Elasticsearch assign document IDs or set them manually yourself.

---

<div class="post-metadata">

**Author:** ![EnJay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enjay/32/100715_2.png) [@EnJay](https://discuss.elastic.co/u/EnJay)\
**Post date:** [January 25, 2022, 8:35pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/7 "2022-01-25T20:35:47Z")

</div>

But the problem is that in the future I will need to search by currency name and time, if only one value is indexed, is it possible to search by two parameters at the same time?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 25, 2022, 8:59pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/8 "2022-01-25T20:59:35Z")

</div>

I do not understand the problem. You can search on multiple fields and combine criteria using [boolean queries](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/query-dsl-bool-query.html).

> [@EnJay](#):
>
> if only one value is indexed

I do not understand what you mean.

---

<div class="post-metadata">

**Author:** ![linkerc](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@linkerc](https://discuss.elastic.co/u/linkerc)\
**Post date:** [January 25, 2022, 9:27pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/9 "2022-01-25T21:27:08Z")

</div>

You need to introduce a new field in your document body to differentiate the currency name. So 2 fields will be indexed.  
"currency name" & "time".  
You search the documents using 2 fields. (currency+time)

It basically moves the old "\_type" value into the document body and you need to add the currency-name to your query string.

Elasticsearch by default will index all the fields in your document body, unless you tell it not to from "mapping". With the above example after the migration, you should have 3 fields getting indexed. "currency name", "time", "price". Unless you changed this behavior from "mapping". Hope it helps.

---

<div class="post-metadata">

**Author:** ![EnJay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enjay/32/100715_2.png) [@EnJay](https://discuss.elastic.co/u/EnJay)\
**Post date:** [January 25, 2022, 9:50pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/10 "2022-01-25T21:50:35Z")

</div>

Thank you very much. Now I understand how it works and why it works 🤗

---

<div class="post-metadata">

**Author:** ![EnJay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enjay/32/100715_2.png) [@EnJay](https://discuss.elastic.co/u/EnJay)\
**Post date:** [January 25, 2022, 9:53pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/11 "2022-01-25T21:53:50Z")

</div>

Thanks for the extra clarification. This helped me too 🤗  
Now i use this request:

```auto
{
  "query": {
    "bool" : {
        "must": [{
          "term": {
            "currency" : "bitcoin"
          }
        },
        {
          "range": {
            "time": {
                "gt": 1642715000000
            }
          }
        }
      ]
        "size": 1
}

```

I hope so right. Although the answer shows the right one, but still, maybe somehow I can improve my query 🙂

---

<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:** [February 22, 2022, 9:54pm UTC](https://discuss.elastic.co/t/differences-in-put-requests-in-es-versions/295171/12 "2022-02-22T21:54:47Z")

</div>

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