Skip to content
Snippets Groups Projects
Commit 1be46b0d authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

fix merge conflicts

parents 0b806153 47407844
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ var search = function() { ...@@ -18,7 +18,7 @@ var search = function() {
$.ajax({ $.ajax({
url:"/search/fetch", url:"/search/fetch",
type: 'get', type: 'get',
data: params.get(), data: params.get_fetch(),
beforeSend: function() { beforeSend: function() {
if (append) { if (append) {
$('.search-more').remove(); $('.search-more').remove();
...@@ -267,6 +267,13 @@ var searchParameters = function() { ...@@ -267,6 +267,13 @@ var searchParameters = function() {
} }
return params[type]; return params[type];
}, },
get_fetch: function() {
var params_to_send = JSON.parse(JSON.stringify(params));
params_to_send.subject = params_to_send.subject.join(', ');
params_to_send.type = params_to_send.type.join(', ');
params_to_send.school_year = params_to_send.school_year.join(', ');
return params_to_send;
},
url: function() { url: function() {
var url = history.state.url.split('?', 1) + "?", var url = history.state.url.split('?', 1) + "?",
keys = Object.keys(params), keys = Object.keys(params),
......
...@@ -7,6 +7,9 @@ class SearchController < ApplicationController ...@@ -7,6 +7,9 @@ class SearchController < ApplicationController
def fetch def fetch
objectsFound = [] objectsFound = []
params[:subject]= params[:subject].split(', ')
params[:type] = params[:type].split(', ')
params[:school_year] = params[:school_year].split(', ')
page=1 page=1
if (params[:page]) if (params[:page])
page = params[:page].to_i page = params[:page].to_i
...@@ -15,9 +18,7 @@ class SearchController < ApplicationController ...@@ -15,9 +18,7 @@ class SearchController < ApplicationController
@pagination_limit=10 @pagination_limit=10
unless params[:query].blank? unless params[:query].blank?
params[:order] = "" if params[:order].blank? objectsFound = search params
objectsFound = search params[:query], params[:order]
@numFound = objectsFound.length @numFound = objectsFound.length
# case params[:order] # case params[:order]
......
...@@ -129,27 +129,29 @@ module OrientDb ...@@ -129,27 +129,29 @@ module OrientDb
# ON LearningObject (name, description) # ON LearningObject (name, description)
# FULLTEXT ENGINE LUCENE # FULLTEXT ENGINE LUCENE
# METADATA {"analyzer":"org.apache.lucene.analysis.br.BrazilianAnalyzer"} # METADATA {"analyzer":"org.apache.lucene.analysis.br.BrazilianAnalyzer"}
def search(qry, order = nil) def search(params)
# TODO: fix search metadata from dspace # TODO: fix search metadata from dspace
order = params[:order]
qry = params[:query]
unless order.nil? unless order.nil?
order = case order order = case order
when "author" when "author"
"metadata.key['dc.contributor.author']" "author"
when "publicationasc" when "publicationasc"
"metadata.key['dc.date.submitted']" "created_at"
when "publicationdesc" when "publicationdesc"
"metadata.key['dc.date.submitted'] DESC" "created_at DESC"
when "title" when "title"
"name ASC" "name ASC"
else else
nil nil
end end
end end
query = "SELECT EXPAND(rid) FROM index:learningobject_search WHERE key LUCENE '#{qry}'" query = "SELECT EXPAND(rid) FROM index:learningobject_search WHERE key LUCENE '#{qry}'"
query = "SELECT * FROM (" + query + ") WHERE " + fetch_types(params[:type]) unless params[:type].blank?
query = "SELECT * FROM (" + query + ") ORDER BY #{order}" unless order.nil? query = "SELECT * FROM (" + query + ") ORDER BY #{order}" unless order.nil?
query = "SELECT @rid.asString(), last_modified FROM (" + query + ")" query = "SELECT @rid.asString(), last_modified FROM (" + query + ")"
learning_objects_hash = connection.query query, limit: 10000 learning_objects_hash = connection.query query, limit: 10000
# return only rids with their modification time # return only rids with their modification time
...@@ -172,6 +174,15 @@ module OrientDb ...@@ -172,6 +174,15 @@ module OrientDb
hash hash
end end
def fetch_types(types)
qry = ''
types.each do |type|
qry = qry + "type = '#{type}' " if type == types.first
qry = qry + "OR type = '#{type}' " if type != types.first
end
qry
end
private private
def accepted_properties def accepted_properties
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<select class="select-tag-container filter-subject" multiple="multiple"> <select class="select-tag-container filter-subject" multiple="multiple">
<option value="Conjunto">Conjuntos</option> <option value="Conjunto">Conjuntos</option>
<option value="Soma">Soma</option> <option value="Soma">Soma</option>
<option value="Álgebra">Álgebra</option> <option value="Algebra">Álgebra</option>
</select> </select>
</div> </div>
<h4 class="dropdown">Biologia<span class="caret caret-align-right"/></h4> <h4 class="dropdown">Biologia<span class="caret caret-align-right"/></h4>
......
module SearchEngine module SearchEngine
module OrientdbLucene module OrientdbLucene
def search(qry, order = nil) def search(params)
learning_object_repository.search(qry, order) learning_object_repository.search(params)
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