Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot define custom mappings #1260

Closed
namila opened this issue May 6, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@namila
Copy link

commented May 6, 2019

Hi,
Below is my setup

searchkick 4.0.0
rails 5.1.7
ruby 2.6.2
ElasticSearch 7.0.1
MacOS 10.14.4

I am trying to define a custom mapping for a field since I need it to be indexed as a float

searchkick word_middle: %i[name product_id category_ids updated_at retail_price retail_price_for_sorting origin_id company_group_id product_group_ids], mappings: { product: { properties: { retail_price_for_sorting: { type: "float"}, } } }, merge_mappings: true

and once I try to reindex I get the following error

Elasticsearch::Transport::Transport::Errors::BadRequest ([400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [product : {properties={retail_price_for_sorting={type=float}}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [product : {properties={retail_price_for_sorting={type=float}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [product : {properties={retail_price_for_sorting={type=float}}}]"}},"status":400})

any thoughts on this?

Thanks in advance :)

@namila

This comment has been minimized.

Copy link
Author

commented May 6, 2019

This issue does not occur with ElasticSearch 6.2.2. But present in ElasticSearch 7.0.1

@ankane

This comment has been minimized.

Copy link
Owner

commented May 6, 2019

Hey @namila, Elasticsearch 7 does not support mapping types. You'll need to remove the root product key.

ES 6

class Product < ApplicationRecord
  searchkick mappings: {
    product: {
      properties: {
        name: {type: "keyword"}
      }
    }
  }
end

ES 7

class Product < ApplicationRecord
  searchkick mappings: {
    properties: {
      name: {type: "keyword"}
    }
  }
end

@ankane ankane closed this May 6, 2019

@namila

This comment has been minimized.

Copy link
Author

commented May 6, 2019

Thanks a lot @ankane :) by the way this is an awesome Gem <3

ankane added a commit that referenced this issue May 7, 2019

@ankane

This comment has been minimized.

Copy link
Owner

commented May 7, 2019

Made root type mapping optional on master with Elasticsearch 6, so the Elasticsearch 7 example above can be used for both versions going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.