lib/searchkick/index.rb in searchkick-3.1.2 vs lib/searchkick/index.rb in searchkick-3.1.3
- old
+ new
@@ -89,20 +89,25 @@
client.indices.update_aliases body: {actions: actions}
end
alias_method :swap, :promote
def retrieve(record)
- client.get(
- index: name,
- type: document_type(record),
- id: search_id(record)
- )["_source"]
+ record_data = RecordData.new(self, record).record_data
+
+ # remove underscore
+ get_options = Hash[record_data.map { |k, v| [k.to_s.sub(/\A_/, "").to_sym, v] }]
+
+ client.get(get_options)["_source"]
end
def all_indices(unaliased: false)
indices =
begin
- client.indices.get_aliases
+ if client.indices.respond_to?(:get_alias)
+ client.indices.get_alias
+ else
+ client.indices.get_aliases
+ end
rescue Elasticsearch::Transport::Transport::Errors::NotFound
{}
end
indices = indices.select { |_k, v| v.empty? || v["aliases"].empty? } if unaliased
indices.select { |k, _v| k =~ /\A#{Regexp.escape(name)}_\d{14,17}\z/ }.keys