added elasticsearch gem and index method
This commit is contained in:
18
front-api/controllers/search.rb
Normal file
18
front-api/controllers/search.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
get '/search/index' do
|
||||
es_client = Elasticsearch::Client.new log: true
|
||||
|
||||
all_items = Item.all.to_a
|
||||
all_items.each do |item|
|
||||
es_client.index index: 'ribica', type: 'items', id: item.id, body: {
|
||||
title: 'Test',
|
||||
name: item.name,
|
||||
code: item.code,
|
||||
description: item.description,
|
||||
sub_category: item.sub_category.name,
|
||||
category: item.sub_category.category.name,
|
||||
section: item.sub_category.category.section.name
|
||||
}
|
||||
end
|
||||
|
||||
"ok".to_json
|
||||
end
|
||||
Reference in New Issue
Block a user