class RediSearcher::Index
Constants
- OPTIONS_FLAGS
- OPTIONS_PARAMS
Attributes
client[R]
name[R]
schema[R]
Public Class Methods
new(client, name, schema)
click to toggle source
# File lib/redi_searcher/index.rb, line 16 def initialize(client, name, schema) @client = client @name = name @schema = RediSearcher::Schema.new(schema) end
Public Instance Methods
create(**options)
click to toggle source
# File lib/redi_searcher/index.rb, line 26 def create(**options) client.call(ft_create(schema, options)) end
drop()
click to toggle source
# File lib/redi_searcher/index.rb, line 44 def drop !client.call(ft_drop()).nil? rescue Redis::CommandError nil end
exists?()
click to toggle source
# File lib/redi_searcher/index.rb, line 40 def exists? !info.nil? end
generate_document(id, fields)
click to toggle source
# File lib/redi_searcher/index.rb, line 22 def generate_document(id, fields) RediSearcher::Document.new(self, id, fields) end
info()
click to toggle source
# File lib/redi_searcher/index.rb, line 30 def info Hash[*client.call(ft_info)] rescue Redis::CommandError nil end
search(query, **options)
click to toggle source
# File lib/redi_searcher/index.rb, line 36 def search(query, **options) client.call(ft_search(query, options)) end
Private Instance Methods
ft_create(schema, **options)
click to toggle source
# File lib/redi_searcher/index.rb, line 52 def ft_create(schema, **options) ['FT.CREATE', name , *serialize_options(:create, options), 'SCHEMA', *schema.serialize] end
ft_drop(**options)
click to toggle source
# File lib/redi_searcher/index.rb, line 56 def ft_drop(**options) ['FT.DROP', name, *serialize_options(:drop, options)] end
ft_info()
click to toggle source
# File lib/redi_searcher/index.rb, line 64 def ft_info ['FT.INFO', name] end
ft_search(query, **options)
click to toggle source
# File lib/redi_searcher/index.rb, line 60 def ft_search(query, **options) ['FT.SEARCH', name, query, *serialize_options(:search, options)] end