lib/redi_search_rails.rb
def ft_search_format(args)
      results = ft_search(args)
      # => transform into array of objects
      output = []
      results.shift  # => remove count
      results.each_slice(2) do |result|
        attributes = {}
        result[1].each_slice(2) do |attribute|
          attributes[attribute[0]] = attribute[1]
        end
        hash = {id: result[0]}.merge(attributes)
        output << OpenStruct.new(hash)
      end
      return output
    rescue Exception => e
      Rails.logger.error e if defined? Rails
      return e.message
    end
def ft_search_format(args)
      results = ft_search(args)
      # => transform into array of objects
      output = []
      results.shift  # => remove count
      results.each_slice(2) do |result|
        attributes = {}
        result[1].each_slice(2) do |attribute|
          attributes[attribute[0]] = attribute[1]
        end
        hash = {id: result[0]}.merge(attributes)
        output << OpenStruct.new(hash)
      end
      return output
    rescue Exception => e
      Rails.logger.error e if defined? Rails
      return e.message
    end
def ft_search_format ( args ) results = ft_search ( args ) # => transform into array of objects output = [ ] results . shift # => remove count results . each_slice ( 2 ) do | result | attributes = { } result [ 1 ] . each_slice ( 2 ) do | attribute | attributes [ attribute [ 0 ] ] = attribute [ 1 ] end hash = { id : result [ 0 ] } . merge ( attributes ) output << OpenStruct . new ( hash ) end return output rescue Exception => e Rails . logger . error e if defined? Rails return e . message end
search the index for specific keyword(s) and return output as array of objects

 @param keyword [String]  'some keyword'
 @param offset [Integer]   default 0
 @param keyword [Integer]  default 10
 @return [Array]   [{"id": "gid://application_name/User/unique_id", "name": "Bob", "age": "100"}, ...]
search the index for specific keyword ( s ) and return output as array of objects