Skip to content

Commit

Permalink
Merge branch 'feature/index-ontology-agent-metadata' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Feb 23, 2024
2 parents 642f28c + f156cdc commit 55e9e38
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ GEM
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.3.1)
google-protobuf (3.25.3-x86_64-darwin)
google-protobuf (3.25.3-x86_64-linux)
googleapis-common-protos (1.4.0)
google-protobuf (~> 3.14)
Expand All @@ -210,6 +211,9 @@ GEM
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
grpc (1.62.0-x86_64-darwin)
google-protobuf (~> 3.25)
googleapis-common-protos-types (~> 1.0)
grpc (1.62.0-x86_64-linux)
google-protobuf (~> 3.25)
googleapis-common-protos-types (~> 1.0)
Expand Down Expand Up @@ -399,6 +403,7 @@ GEM
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
x86_64-darwin-23
x86_64-linux

DEPENDENCIES
Expand Down Expand Up @@ -456,4 +461,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.3.14
2.4.21
13 changes: 13 additions & 0 deletions controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ class AdminController < ApplicationController
reply(200, collection_schema)
end


post '/collections/:collection/search' do
collection = params[:collection].to_sym

search_keys = %w[defType fq qf sort start rows fl stopwords lowercaseOperators]

search_params = params.select { |key, _| search_keys.include?(key) }
search_query = params[:query] || params[:q]
search_query = search_query.blank? ? '*' : search_query

reply(200, Goo.search_connections[collection].search(search_query, search_params).to_h)
end

post '/index_batch/:model_name' do
error 500, "model_name parameter not set" if params["model_name"].blank?

Expand Down
20 changes: 20 additions & 0 deletions test/controllers/test_search_models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ def test_collection_schema
assert_includes fields, 'resource_model'
end

def test_collection_search

count, acronyms, bro = LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: false,
acronym: "BROSEARCHTEST",
name: "BRO Search Test",
file_path: "./test/data/ontology_files/BRO_v3.2.owl",
ont_count: 1,
submission_count: 1,
ontology_type: "VALUE_SET_COLLECTION"
})
collection = 'ontology_metadata'
post "/admin/search/collections/#{collection}/search", {q: ""}

assert last_response.ok?
res = MultiJson.load(last_response.body)
assert_equal 2, res['response']['numFound']
end


def test_ontology_metadata_search
count, acronyms, bro = LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: false,
Expand Down

0 comments on commit 55e9e38

Please sign in to comment.