Skip to content

Commit

Permalink
fix(search): highlight decorator search on smart field (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasalexandre9 authored Dec 9, 2024
1 parent 9646772 commit 69e2cac
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 286 deletions.
285 changes: 0 additions & 285 deletions Gemfile.lock

This file was deleted.

1 change: 1 addition & 0 deletions app/services/forest_liana/search_query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def perform(resource)
if field.try(:[], :search)
begin
@records = field[:search].call(@records, @search)
(@fields_searched << field[:field].to_s) if field[:type] == 'String'
rescue => exception
FOREST_REPORTER.report exception
FOREST_LOGGER.error "Cannot search properly on Smart Field:\n" \
Expand Down
7 changes: 6 additions & 1 deletion spec/dummy/lib/forest_liana/collections/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ class Forest::User
"name IS '#{capitalize_name}'"
end

field :cap_name, type: 'String', filter: filter_cap_name do
search_cap_name = lambda do |query, search|
# Injects your new filter into the query.
query.or(User.where("name = '#{search}'"))
end

field :cap_name, type: 'String', filter: filter_cap_name, search: search_cap_name do
object.name.upcase
end

Expand Down
Loading

0 comments on commit 69e2cac

Please sign in to comment.