Skip to content

can't search with mongoid #250

Closed
Closed
@masukomi

Description

@masukomi

context: a Task model in a rails app backed with Mongoid. ms_search will never work because it always assumes columns

The relevant comment from the code:

    # The condition_key must be a valid column otherwise, the `.where` below will not work
   # Since we provide a way to customize the primary_key value, `ms_pk(meilisearch_options)` may not
   # respond with a valid database column. The blocks below prevent that from happening.

There will never be a "valid column" in MongoDB. Columns don't exist in document databases.

Expected behavior
not to try and call .columns when using mongoid

Current behavior
💥 because mongoid doesn't have a columns method (MongoDB is a document database so it wouldn't make sense)

/Users/masukomi/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/meilisearch-rails-0.9.0/lib/meilisearch-rails.rb:645:in `ms_search': undefined method `columns' for Task:Class (NoMethodError)

                                     meilisearch_options[:type].columns.map(&:name).map(&:to_s).exclude?(condition_key.to_s)

Environment (please complete the following information):

  • OS: [macOS]
  • Meilisearch server version: [e.g. v.1.1.1] (irrelevant though)
  • meilisearch-rails version: [e.g v0.9.0]
  • Rails version: [e.g. 7.0.4.3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions