meilisearch / meilisearch-rails

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

Add support for highlight_pre_tag and highlight_post_tag #239

Closed doutatsu closed 1 year ago

doutatsu commented 1 year ago

Description It looks like I cannot make use of these two fields, which are part of Meilisearch. It's quite annoying having to modify in place myself, instead of making use of existing functionality.

Basic example With this basic configuration:

  meilisearch enqueue: :reindex_search do
    searchable_attributes %i[title alt_titles]
    filterable_attributes %i[content_rating content_type]
    sortable_attributes %i[created_at available_chapters_count users_count]
    attributes_to_highlight %i[title alt_titles]
    highlight_pre_tag "<strong>"
    highlight_post_tag "</strong>"
    pagination max_total_hits: 50_000
  end

And error is thrown

NoMethodError (undefined method `highlight_pre_tag' for #<MeiliSearch::Rails::IndexSettings:0x00000001149327f8 @options={:enqueue=>:reindex_search}, @searchableAttributes=[:title, :alt_titles], @filterableAttributes=[:content_rating, :content_type], @sortableAttributes=[:created_at, :available_chapters_count, :users_count], @attributesToHighlight=[:title, :alt_titles]>):

Other Any other things you want to add.

brunoocasali commented 1 year ago

Hi @doutatsu, thanks for using Meilisearch!

I will investigate your bug report, and I'll let you updated as soon as possible!

brunoocasali commented 1 year ago

Ok, I thought it could be something related to the camel casing we have internally in the gem, but there is no problem with that. I created a used case that covers the usage, so no problem at all there.

The problem is similar to the one you reported at #240.

Those options are not available as configure-time, only during search time. So this is not a bug :)

doutatsu commented 1 year ago

Ah my bad, I should read the documentation better, to make sure I spot the difference between runtime and configure options. So are all the existing configurations available in meilisearch are supported by the gem at this point?

brunoocasali commented 1 year ago

Ah my bad, I should read the documentation better, to make sure I spot the difference between runtime and configure options.

No problem, I'm here to help! Also, if you think the documentation is not good enough PRs are always welcome!

So are all the existing configurations available in meilisearch are supported by the gem at this point?

Yes, most of them, all the unsupported options are described in the issues like this. In any case, you can open an issue, and we can help you :)