diff --git a/app/models/reference_repository.rb b/app/models/reference_repository.rb index e8d54e579..fa43da61d 100644 --- a/app/models/reference_repository.rb +++ b/app/models/reference_repository.rb @@ -102,8 +102,14 @@ def as_indexed_json(_options = {}) indexes :client_id indexes :re3doi indexes :re3data_url - indexes :created_at, type: :date, format: :date_optional_time - indexes :updated_at, type: :date, format: :date_optional_time + indexes :created_at, type: :date, format: :date_optional_time, + fields: { + created_sort: { type: :date } + } + indexes :updated_at, type: :date, format: :date_optional_time, + fields: { + updated_sort: { type: :date } + } indexes :name indexes :alternate_name indexes :description @@ -273,7 +279,7 @@ def query(query, options = {}) def sort_fields [ { _score: { order: "desc" } }, - { created_at: { order: "asc" } }, + { "created_at.created_sort": { order: "asc" } }, { "uid.raw": { order: "asc" } }, ] end diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb index e351ffbef..d402e2062 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -471,10 +471,10 @@ end before :all do + ReferenceRepository.import(force: true) VCR.use_cassette("ReferenceRepositoryType/re3Data/R3XS37") do @client = create(:client) @ref_repo = create(:reference_repository, client_id: @client.uid, re3doi: "10.17616/R3XS37") - ReferenceRepository.import sleep 2 end end