Skip to content

Commit

Permalink
Merge branch 'feature/index-ontology-agent-metadata' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Mar 9, 2024
2 parents 1b81e51 + 61bec78 commit 139fb8e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
29 changes: 24 additions & 5 deletions controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,33 @@ class AdminController < ApplicationController

all_attrs = get_attributes_to_include([:all], model)

collection = model.where.include(all_attrs).all
collections = model.where.include(all_attrs).all
indexed = []
not_indexed = []
collections.each do |m|
begin
response = m.index.dig("responseHeader", "status")
if response.eql?(0)
indexed << m.id
else
not_indexed << m.id
end
rescue StandardError
not_indexed << m.id
end
end

response = model.indexBatch(collection).dig("responseHeader", "status")
if !indexed.empty?
msg = "Batch indexing for #{model.model_name} completed for"

if response.eql?(0)
reply(200, "Batch indexing for #{model.model_name} complete")
if not_indexed.empty?
msg += " all models"
else
msg += " #{indexed.join(', ')} and not for the following #{not_indexed.join(', ')}, see logs for more details"
end
reply(200, msg)
else
reply(500, "Batch indexing for #{model.model_name} failed: #{response}")
reply(500, "Batch indexing for #{model.model_name} failed")
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ class SearchController < ApplicationController


conn = SOLR::SolrConnector.new(Goo.search_conf, :ontology_data)

resp = conn.search(query, fq: fq, qf: qf,
resp = conn.search(query, fq: fq, qf: qf, defType: "edimax",
page: page, page_size: page_size)

total_found = resp["response"]["numFound"]
Expand Down

0 comments on commit 139fb8e

Please sign in to comment.