Skip to content
Snippets Groups Projects
Commit 8850e2f0 authored by Felipe Bombardelli's avatar Felipe Bombardelli
Browse files

Add the function autocomplete in the controller

parent 10ea1db2
No related branches found
No related tags found
No related merge requests found
class SearchController < ApplicationController class SearchController < ApplicationController
include SearchEngine::OrientdbLucene include SearchEngine::OrientdbLucene
def index def index
end end
...@@ -45,6 +46,20 @@ class SearchController < ApplicationController ...@@ -45,6 +46,20 @@ class SearchController < ApplicationController
render partial: 'search/fetch' render partial: 'search/fetch'
end end
def autocomplete
begin
query = params["q"] || ""
json_data = open( "http://localhost:4242?q=#{query}" ).read
render text: json_data
rescue
render text: "[]"
end
end
private private
def build_page_result(objects, page, limit) def build_page_result(objects, page, limit)
...@@ -59,4 +74,6 @@ class SearchController < ApplicationController ...@@ -59,4 +74,6 @@ class SearchController < ApplicationController
# items.each{ |item| item['author'] = order_author(item['author']) if (item['author'].nil? ? [] : item['author']).size > 0 } # items.each{ |item| item['author'] = order_author(item['author']) if (item['author'].nil? ? [] : item['author']).size > 0 }
items items
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment