app/models/data_file.rb
def matching_models

    results = {}

    if Seek::Config.solr_enabled && contains_extractable_spreadsheet?
      search_terms = spreadsheet_annotation_search_fields | content_blob_search_terms | fs_search_fields | searchable_tags
      #make the array uniq! case-insensistive whilst mainting the original case
      dc = []
      search_terms = search_terms.inject([]) do |r,v|
        unless dc.include?(v.downcase)
          r << v
          dc << v.downcase
        end
        r
      end
      search_terms.each do |key|
        key = Seek::Search::SearchTermFilter.filter(key)
        unless key.blank?
          Model.search do |query|
            query.keywords key, :fields=>[:model_contents_for_search, :description, :searchable_tags]
          end.hits.each do |hit|
            unless hit.score.nil?
              results[hit.primary_key]||=ModelMatchResult.new([],0,hit.primary_key)
              results[hit.primary_key].search_terms << key
              results[hit.primary_key].score += hit.score
            end
          end
        end
      end
    end

    results.values.sort_by{|a| -a.score}
  end
#return a an array of ModelMatchResult where the model id is the key, and the matching terms/values are the values
return a an array of ModelMatchResult where the model id is the key, and the matching terms/values are the values
return a an array of ModelMatchResult where the model id is the key and the matching terms / values are the values
def matching_models
    results = {}
    if Seek::Config.solr_enabled && contains_extractable_spreadsheet?
      search_terms = spreadsheet_annotation_search_fields | content_blob_search_terms | fs_search_fields | searchable_tags
      dc = []
      search_terms = search_terms.inject([]) do |r,v|
        unless dc.include?(v.downcase)
          r << v
          dc << v.downcase
        end
        r
      end
      search_terms.each do |key|
        key = Seek::Search::SearchTermFilter.filter(key)
        unless key.blank?
          Model.search do |query|
            query.keywords key, :fields=>[:model_contents_for_search, :description, :searchable_tags]
          end.hits.each do |hit|
            unless hit.score.nil?
              results[hit.primary_key]||=ModelMatchResult.new([],0,hit.primary_key)
              results[hit.primary_key].search_terms << key
              results[hit.primary_key].score += hit.score
            end
          end
        end
      end
    end
    results.values.sort_by{|a| -a.score}
  end
def matching_models results = { } if Seek :: Config . solr_enabled && contains_extractable_spreadsheet? search_terms = spreadsheet_annotation_search_fields | content_blob_search_terms | fs_search_fields | searchable_tags dc = [ ] search_terms = search_terms . inject ( [ ] ) do | r , v | unless dc . include? ( v . downcase ) r << v dc << v . downcase end r end search_terms . each do | key | key = Seek :: Search :: SearchTermFilter . filter ( key ) unless key . blank? Model . search do | query | query . keywords key , :fields => [ :model_contents_for_search , :description , :searchable_tags ] end . hits . each do | hit | unless hit . score . nil? results [ hit . primary_key ] ||= ModelMatchResult . new ( [ ] , 0 , hit . primary_key ) results [ hit . primary_key ] . search_terms << key results [ hit . primary_key ] . score += hit . score end end end end end results . values . sort_by { | a | - a . score } end
return a an array of ModelMatchResult where the model id is the key, and the matching terms/values are the values
return a an array of ModelMatchResult where the model id is the key and the matching terms / values are the values
#make the array uniq! case-insensistive whilst mainting the original case