Skip to content

Commit

Permalink
make id lookup case insensitive. #403
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 28, 2020
1 parent 1198f95 commit dafce67
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions app/models/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Client < ActiveRecord::Base
} do
mapping dynamic: 'false' do
indexes :id, type: :keyword
indexes :uid, type: :keyword, normalizer: "keyword_lowercase"
indexes :symbol, type: :keyword
indexes :provider_id, type: :keyword
indexes :consortium_id, type: :keyword
Expand Down
32 changes: 16 additions & 16 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Doi < ActiveRecord::Base
} do
mapping dynamic: 'false' do
indexes :id, type: :keyword
indexes :uid, type: :keyword
indexes :uid, type: :keyword, normalizer: "keyword_lowercase"
indexes :doi, type: :keyword
indexes :identifier, type: :keyword
indexes :url, type: :text, fields: { keyword: { type: "keyword" }}
Expand All @@ -150,12 +150,12 @@ class Doi < ActiveRecord::Base
schemeUri: { type: :keyword }
}},
}
indexes :contributors, type: :object, properties: {
indexes :contributors, type: :object, properties: {
nameType: { type: :keyword },
nameIdentifiers: { type: :object, properties: {
nameIdentifier: { type: :keyword },
nameIdentifierScheme: { type: :keyword },
schemeUri: { type: :keyword }
schemeUri: { type: :keyword },
}},
name: { type: :text },
givenName: { type: :text },
Expand Down Expand Up @@ -198,7 +198,7 @@ class Doi < ActiveRecord::Base
}
indexes :identifiers, type: :object, properties: {
identifierType: { type: :keyword },
identifier: { type: :keyword }
identifier: { type: :keyword },
}
indexes :related_identifiers, type: :object, properties: {
relatedIdentifierType: { type: :keyword },
Expand All @@ -207,15 +207,15 @@ class Doi < ActiveRecord::Base
relatedMetadataScheme: { type: :keyword },
schemeUri: { type: :keyword },
schemeType: { type: :keyword },
resourceTypeGeneral: { type: :keyword }
resourceTypeGeneral: { type: :keyword },
}
indexes :types, type: :object, properties: {
resourceTypeGeneral: { type: :keyword },
resourceType: { type: :keyword },
schemaOrg: { type: :keyword },
bibtex: { type: :keyword },
citeproc: { type: :keyword },
ris: { type: :keyword }
ris: { type: :keyword },
}
indexes :funding_references, type: :object, properties: {
funderName: { type: :keyword },
Expand Down Expand Up @@ -377,30 +377,30 @@ class Doi < ActiveRecord::Base
} },
secondary_billing_contact: { type: :object, properties: {
email: { type: :text },
given_name: { type: :text},
family_name: { type: :text }
given_name: { type: :text },
family_name: { type: :text },
} },
service_contact: { type: :object, properties: {
email: { type: :text },
given_name: { type: :text},
family_name: { type: :text }
given_name: { type: :text },
family_name: { type: :text },
} },
secondary_service_contact: { type: :object, properties: {
email: { type: :text },
given_name: { type: :text},
family_name: { type: :text }
given_name: { type: :text },
family_name: { type: :text },
} },
voting_contact: { type: :object, properties: {
email: { type: :text },
given_name: { type: :text},
family_name: { type: :text }
given_name: { type: :text },
family_name: { type: :text },
} },
created: { type: :date },
updated: { type: :date },
deleted_at: { type: :date },
cumulative_years: { type: :integer, index: "false" },
consortium: { type: :object },
consortium_organizations: { type: :object }
consortium_organizations: { type: :object },
}
indexes :resource_type, type: :object
# indexes :view_ids, type: :keyword
Expand Down Expand Up @@ -517,7 +517,7 @@ def self.sub_aggregations
end

def self.query_fields
['doi^50', 'id^50', 'titles.title^3', 'creator_names^3', 'creators.name^3', 'creators.id^3', 'publisher^3', 'descriptions.description^3', 'types.resourceTypeGeneral^3', 'subjects.subject^3', 'identifiers.identifier^3', 'related_identifiers.relatedIdentifier^3', '_all']
["uid^50", "doi^50", 'titles.title^3', 'creator_names^3', 'creators.name^3', 'creators.id^3', 'publisher^3', 'descriptions.description^3', 'types.resourceTypeGeneral^3', 'subjects.subject^3', 'identifiers.identifier^3', 'related_identifiers.relatedIdentifier^3', '_all']
end

# return results for one or more ids
Expand Down
5 changes: 4 additions & 1 deletion app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ class Provider < ActiveRecord::Base
analyzer: {
string_lowercase: { tokenizer: 'keyword', filter: %w(lowercase ascii_folding) }
},
normalizer: {
keyword_lowercase: { type: "custom", filter: %w(lowercase) }
},
filter: { ascii_folding: { type: 'asciifolding', preserve_original: true } }
}
} do
mapping dynamic: 'false' do
indexes :id, type: :keyword
indexes :uid, type: :keyword
indexes :uid, type: :keyword, normalizer: "keyword_lowercase"
indexes :symbol, type: :keyword
indexes :globus_uuid, type: :keyword
indexes :client_ids, type: :keyword
Expand Down

0 comments on commit dafce67

Please sign in to comment.