Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
guille-sage committed Oct 23, 2023
1 parent 3fe6364 commit f5725a7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'json', '2.1.0'
gem 'json'

# Specify your gem's dependencies in elastic_search_framework.gemspec
gemspec
Expand Down
1 change: 1 addition & 0 deletions elastic_search_framework.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'pry-byebug'
spec.add_dependency 'hash_kit', '~> 0.5'
spec.add_dependency 'json'
spec.add_dependency 'connection_pool'
Expand Down
6 changes: 3 additions & 3 deletions lib/elastic_search_framework/index_alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ def get_item(id:, type: "default", routing_key: nil)
options = { index: self, id: id, type: type }
options[:routing_key] = routing_key if active_index.routing_enabled? && routing_key

repository.get(options)
repository.get(**options)
end

def put_item(type: "default", item:, op_type: 'index', routing_key: nil)
indexes.each do |index|
options = { entity: item, index: index[:klass], type: type, op_type: op_type }
options[:routing_key] = routing_key if index[:klass].routing_enabled? && routing_key

repository.set(options)
repository.set(**options)
end
end

Expand All @@ -146,7 +146,7 @@ def delete_item(id:, type: "default", routing_key: nil)
options = { index: index[:klass], id: id, type: type }
options[:routing_key] = routing_key if index[:klass].routing_enabled? && routing_key

repository.drop(options)
repository.drop(**options)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elastic_search_framework/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def drop(index:, id:, type: 'default', routing_key: nil)
end

def query(index:, expression:, type: 'default', limit: 10, count: false, routing_key: nil)
uri_string = "#{host}/#{index.full_name}/#{type}/_search?q=#{URI.encode(expression)}&size=#{limit}"
uri_string = "#{host}/#{index.full_name}/#{type}/_search?q=#{CGI::escape(expression)}&size=#{limit}"
uri_string += "&routing=#{routing_key}" if routing_key

uri = URI(uri_string)
Expand Down

0 comments on commit f5725a7

Please sign in to comment.