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

filterableAttributes not set #319

Open
jeremylynch opened this issue Feb 5, 2024 · 4 comments
Open

filterableAttributes not set #319

jeremylynch opened this issue Feb 5, 2024 · 4 comments
Labels
needs more info This issue needs a minimal complete and verifiable example

Comments

@jeremylynch
Copy link

jeremylynch commented Feb 5, 2024

We have recently upgraded to meilisearch 1.6.0, and are using meilisearch-rails 0.10.2.

We recently ran into an issue where we had to delete an index and then re-create it. However, after deleting the index, and then manually reindexing the model (Offer.reindex), we had an error for Attribute "manufacturer.name" is not filterable.

As shown below, the filterable_attributes are clearly defined under the model:

filterable_attributes [
    'manufacturer.name'
]

To fix this, I had to manually execute the below:

client.index(‘Offer_production’).update_filterable_attributes([
  ‘manufacturer.name’
])

Why would the filterable_attributes not have been automatically set when calling Manufacturer.reindex!? Is this gem compatible with Meilisearch 1.6 ?

@curquiza
Copy link
Member

curquiza commented Feb 8, 2024

Hello @jeremylynch
Thanks for the report!

@ellnix if you are around, I would love to have your help on this 😊 Do you know where it could come from?
Thank you very much for your help

@ellnix
Copy link
Collaborator

ellnix commented Feb 8, 2024

There are models with filterable_attributes set in the test suite and they seem to be behaving normally. There have been some changes to the settings logic but they are not included in v0.10.2.

... reindexing the model (Manufacturer.reindex), ...

As shown below, the filterable_attributes are clearly defined under the model:

filterable_attributes [
    'manufacturer.name'
]

This does not look like it was defined in the Manufacturer model, but rather an Offer model of some kind (judging by the index name). If I am correct, then this block would have been run on Offer.reindex!, not Manufacturer.reindex!.

If that is not the case let me ask some follow up questions:

  1. Did the error appear when you attempted to search or during the reindex?
  2. Is the Offer_production index set on the Manufacturer model?
  3. Is deleting and rebuilding Manufacturer indexes the only change in your use that could relate to this error? Were other indexes rebuilt?

@curquiza curquiza added the needs more info This issue needs a minimal complete and verifiable example label Feb 8, 2024
@jeremylynch
Copy link
Author

jeremylynch commented Feb 9, 2024

Apologies, in my original issue I had Manufacturer.reindex! this should have been Offer.reindex! which created the confusion in your question (I have since edited the original question).

The issue was cause by simply deleting the index, and then attempting to reindex all the records (with Offer.reindex!)

@NielXu
Copy link

NielXu commented Oct 30, 2024

I encountered the same issue:

  1. First delete an existing index
  2. Then reindex! it and the settings are gone

Meilisearch definition:

  meilisearch enqueue: :sync_article_to_meilisearch do
    searchable_attributes [:title, :description]
    filterable_attributes [:id, :type]
    attribute :type
    attribute :title
    attribute :created_at
    attribute :description
    attribute :published
  end

  def self.sync_article_to_meilisearch(article, remove)
    if published && !remove
      article.index!
    else
      Article.index.delete_document(article.id)
    end
  end

Then I call

Article.index.delete # Make sure the index does not exist
Article.reindex!

The settings

irb(main):004:0> Article.index.settings
=> 
{"displayedAttributes"=>["*"],                                                                            
 "searchableAttributes"=>["*"],                                                                           
 "filterableAttributes"=>[],                                                                              
 "sortableAttributes"=>[],                                                                                
 "rankingRules"=>["words", "typo", "proximity", "attribute", "sort", "exactness"],                        
 "stopWords"=>[],                                                                                         
 "synonyms"=>{},                                                                                          
 "distinctAttribute"=>nil,                                                                                
 "typoTolerance"=>{"enabled"=>true, "minWordSizeForTypos"=>{"oneTypo"=>5, "twoTypos"=>9}, "disableOnWords"=>[], "disableOnAttributes"=>[]},
 "faceting"=>{"maxValuesPerFacet"=>100},                                                                  
 "pagination"=>{"maxTotalHits"=>1000}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs a minimal complete and verifiable example
Projects
None yet
Development

No branches or pull requests

4 participants