From dafce67b9c125b4c4bea130b4c7f23f128ad16ae Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 28 Jan 2020 23:00:28 +0000 Subject: [PATCH] make id lookup case insensitive. #403 --- app/models/client.rb | 1 + app/models/doi.rb | 32 ++++++++++++++++---------------- app/models/provider.rb | 5 ++++- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/models/client.rb b/app/models/client.rb index 34af0e89b..89b415a20 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -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 diff --git a/app/models/doi.rb b/app/models/doi.rb index 0f45691e2..d465a7c79 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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" }} @@ -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 }, @@ -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 }, @@ -207,7 +207,7 @@ 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 }, @@ -215,7 +215,7 @@ class Doi < ActiveRecord::Base schemaOrg: { type: :keyword }, bibtex: { type: :keyword }, citeproc: { type: :keyword }, - ris: { type: :keyword } + ris: { type: :keyword }, } indexes :funding_references, type: :object, properties: { funderName: { type: :keyword }, @@ -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 @@ -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 diff --git a/app/models/provider.rb b/app/models/provider.rb index 664326b65..5698eda1c 100644 --- a/app/models/provider.rb +++ b/app/models/provider.rb @@ -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