meilisearch / meilisearch-rails

Meilisearch integration for Ruby on Rails
https://www.meilisearch.com
MIT License
295 stars 47 forks source link

Meilisearch Ruby now expects snake_cased attributes instead of camelCase. #311

Closed coder2000 closed 3 months ago

coder2000 commented 9 months ago

Description Deprecation warning with current Meilisearch Ruby version says that attributes will need to be snake_case in future versions.

Screenshots or Logs

Attributes will be expected to be snake_case in future versions of Meilisearch Ruby.

Non-conforming attributes: filterableAttributes, sortableAttributes
ellnix commented 9 months ago

Could you provide the meilisearch configuration block in your model that is causing this warning?

coder2000 commented 9 months ago

Here it is, and it is all configuration blocks not just one.

  meilisearch do
    attribute :name, :brand_name, :state_name, :created_at, :region_name, :brand_id

    attribute :state_abbr do
      state_abbreviation
    end

    attribute :store_chain do
      store_chain_name || "Independent"
    end

    attribute :region_id do
      region.id
    end

    filterable_attributes [:brand_name, :state_abbr, :region_name, :region_id, :brand_id]
    sortable_attributes [:state_name, :brand_name, :region_name, :store_chain, :name]
  end
ellnix commented 8 months ago

It does not happen to me on a brand new rails app and I cannot tell what could be causing the issue. The camel cased filterableAttributes and sortableAttributes do not appear in the source code at all, and this warning does occur in the test suite even though it has many meilisearch blocks.

Some follow up questions if you don't mind answering:

  1. Are you manually creating a meilisearch index anywhere in your code?
  2. When precisely does this happen? After a record is created, when a search is run, when the app launches?
  3. Are you manually adding documents to the ms index anywhere?
coder2000 commented 8 months ago
  1. What do you mean? I only have the meilisearch blocks on my models
  2. It happens when a record is added or updated
  3. Again what exactly do you mean by manual? With the rails console?
ellnix commented 8 months ago
2. It happens when a record is added or updated

Thank you

  1. What do you mean? I only have the meilisearch blocks on my models
    1. Again what exactly do you mean by manual? With the rails console?

By manual I meant doing something like Product.index.add_documents(...) directly (judging from your response you are not doing that). I will look into this and try to reproduce it again.

brunoocasali commented 7 months ago

@coder2000, are you still having the issue after @ellnix's help? Can you confirm your gems (meilisearch-ruby and meilisearch-rails are the latest?

ellnix commented 7 months ago

I didn't really help in any way. I tried but could not reproduce it, left the issue open to follow up if and when we refactored the gem.

coder2000 commented 3 months ago

I'm not seeing this anymore with the latest version of the gem so I will close it.