# Elastic badrequest error: contains unrecognized parameter: \[type\]

**URL:** <https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427>\
**Category:** Elasticsearch\
**Created:** [February 16, 2024, 2:35am UTC](https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427 "2024-02-16T02:35:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vicapelli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vicapelli/32/131810_2.png) [@Vicapelli](https://discuss.elastic.co/u/Vicapelli)\
**Post date:** [February 16, 2024, 2:35am UTC](https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427/1 "2024-02-16T02:35:27Z")

</div>

I am using Elasticsearch in a Rails application through the Elasticsearch-rails gem. After creating the indexes, I want to import the data into these indexes. But I am getting the following error:

```auto
Elastic::Transport::Transport::Errors::BadRequest ([400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/social_contacts/_bulk] contains unrecognized parameter: [type]"}],"type":"illegal_argument_exception","reason":"request [/social_contacts/_bulk] contains unrecognized parameter: [type]"},"status":400})

```

I've got confused while googling about this error. So I appreciate it if anyone can help me.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [February 16, 2024, 2:43am UTC](https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427/2 "2024-02-16T02:43:00Z")

</div>

Hello and welcome,

What is the request you are making? And what is the version of Elasticsearch you are using?

It seems that your request is including a `type`, types were deprecated in Elasticsearch 7.0 (2019) and removed in Elasticsearch 8.

You can read the post explaining this [here](https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0).

---

<div class="post-metadata">

**Author:** ![Vicapelli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vicapelli/32/131810_2.png) [@Vicapelli](https://discuss.elastic.co/u/Vicapelli)\
**Post date:** [February 16, 2024, 2:53am UTC](https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427/3 "2024-02-16T02:53:45Z")

</div>

Thanks for the quick response.  
I am using these versions:

```auto
 elasticsearch (8.12.2)
 elasticsearch-model (7.1.1)
 elasticsearch-rails (7.2.1)

```

The following snippet of code is my model configuration:

```auto
module Searchable
  extend ActiveSupport::Concern

  included do
    include Elasticsearch::Model
    include Elasticsearch::Model::Callbacks

    settings index: { number_of_shards: 1 } do
      mappings dynamic: 'false' do
        # Define your mapping properties here if needed
        indexes :name
      end
    end

    def self.search(query)
      # Your search logic goes here
      # For example: self. __elasticsearch__.search(query).records.to_a
    end
  end
end

```

And then while connected to the database I run the commands to create index: `Model. __elasticsearch__.create_index!` and after that import to these index `Model. __elasticsearch__.import` thats when i get the error.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [February 16, 2024, 12:54pm UTC](https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427/4 "2024-02-16T12:54:18Z")

</div>

It seems that `elasticsearch-rails` and `elastiscsearch-model` do not support version 8.X yet as you can check [here](https://github.com/elastic/elasticsearch-rails?tab=readme-ov-file#compatibility) and also [here](https://github.com/elastic/elasticsearch-rails/issues/1035).

---

<div class="post-metadata">

**Author:** ![Vicapelli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vicapelli/32/131810_2.png) [@Vicapelli](https://discuss.elastic.co/u/Vicapelli)\
**Post date:** [February 17, 2024, 9:45pm UTC](https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427/5 "2024-02-17T21:45:37Z")

</div>

You got it! My bad for such mistake 😅 Thanks a lot

---

<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 16, 2024, 9:46pm UTC](https://discuss.elastic.co/t/elastic-badrequest-error-contains-unrecognized-parameter-type/353427/6 "2024-03-16T21:46:16Z")

</div>

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