ontology_search.rb revision 9761530c96f0c65cf46998dafc145508802701c7
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenrequire 'json'
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Beware! This is not tested well.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen unless Ontology.where("name = :prefix", prefix: prefix).empty?
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen unless Entity.where("name = :prefix", prefix: prefix).empty?
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen Ontology.select(:name).where("name ILIKE :prefix", prefix: "#{prefix}%").group("name").limit(5).each do |ontology|
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen Entity.select(:name).where("name ILIKE :prefix", prefix: "#{prefix}%").group("name").limit(5).each do |symbol|
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen Logic.select(:name).where("name ILIKE :prefix", prefix: "#{prefix}%").limit(5).each do |logic|
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen Ontology.where("name = :name", name: "#{keyword}").limit(50).each do |ontology|
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen Entity.where("name = :name", name: "#{keyword}").limit(50).each do |symbol|
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen keyword_hash[symbol.ontology.id] ||= symbol.ontology
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen logic.ontologies.each { |o| keyword_hash[o.id] ||= o }
659fe5d24825b160cae512538088020d97a60239Timo Sirainen keyword_hash.each_key { |key| hash[key] ||= ontology_hash[key] }