Skip to content

Commit

Permalink
support queries for events
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 8, 2019
1 parent f9d1ded commit cf755ad
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,23 @@ def query(query, options={})
elsif self.name == "Doi"
must << { terms: { aasm_state: options[:state].to_s.split(",") }} if options[:state].present?
must << { range: { registered: { gte: "#{options[:registered].split(",").min}||/y", lte: "#{options[:registered].split(",").max}||/y", format: "yyyy" }}} if options[:registered].present?
elsif self.name == "Event"
must << { term: { subj_id: options[:subj_id] }} if options[:subj_id].present?
must << { term: { obj_id: options[:obj_id] }} if options[:obj_id].present?
must << { term: { citation_type: options[:citation_type] }} if options[:citation_type].present?
must << { term: { year_month: options[:year_month] }} if options[:year_month].present?
must << { range: { "subj.datePublished" => { gte: "#{options[:publication_year].split("-").min}||/y", lte: "#{options[:publication_year].split("-").max}||/y", format: "yyyy" }}} if options[:publication_year].present?
must << { range: { occurred_at: { gte: "#{options[:occurred_at].split("-").min}||/y", lte: "#{options[:occurred_at].split("-").max}||/y", format: "yyyy" }}} if options[:occurred_at].present?
must << { terms: { prefix: options[:prefix].split(",") }} if options[:prefix].present?
must << { terms: { doi: options[:doi].downcase.split(",") }} if options[:doi].present?
must << { terms: { orcid: options[:orcid].split(",") }} if options[:orcid].present?
must << { terms: { isni: options[:isni].split(",") }} if options[:isni].present?
must << { terms: { subtype: options[:subtype].split(",") }} if options[:subtype].present?
must << { terms: { source_id: options[:source_id].split(",") }} if options[:source_id].present?
must << { terms: { relation_type_id: options[:relation_type_id].split(",") }} if options[:relation_type_id].present?
must << { terms: { registrant_id: options[:registrant_id].split(",") }} if options[:registrant_id].present?
must << { terms: { registrant_id: options[:provider_id].split(",") }} if options[:provider_id].present?
must << { terms: { issn: options[:issn].split(",") }} if options[:issn].present?
end

# ES query can be optionally defined in different ways
Expand Down

0 comments on commit cf755ad

Please sign in to comment.