Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Hyrax::PcdmCollection resources in search results #5515

Merged
merged 3 commits into from Mar 9, 2022

Conversation

cjcolvar
Copy link
Member

@cjcolvar cjcolvar commented Mar 9, 2022

Fixes #5463

Journey to getting Hyrax::PcdmCollection resources to show in search results:

  • Added additional values to Hyrax::CollectionName to force Rails to resolve view partials to hyrax/collections/collection. Without this change Rails was looking in hyrax/hyrax/pcdm_collections/pcdm_collection when attempting to render a SolrDocument with has_model_ssim: Hyrax::PcdmCollection (See https://github.com/samvera/hyrax/blob/main/lib/hyrax/active_fedora_dummy_model.rb#L53)
  • Copied catalog/_index_headers_list_collection.html.erb to catalog/_index_headers_list_hyrax_pcdm_collection.html.erb so Blacklight could find it. This seemed simpler than overriding Blacklight's helper which looks for partials to render (See https://github.com/projectblacklight/blacklight/blob/v6.24.0/app/helpers/blacklight/render_partials_helper.rb#L128-L146)
  • Cloned a simple feature test that shows work and collection search results to reconfigure it to work with valkyrie resources and the valkyrie solr index.
  • To get the tests to pass I added an around hook which changes the blacklight config for the CatalogController to point to the valkyrie solr core instead of the normal hyrax-test core.
  • I also had to modify the basic_metadata.yaml to have the description field be indexed like it is in ActiveFedora work and collection models since the feature test finds the collection by its description.

@samvera/hyrax-code-reviewers

@cjcolvar cjcolvar changed the title Pcdm collection search results Show Hyrax::PcdmCollection resources in search results Mar 9, 2022
Copy link
Contributor

@elrayle elrayle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good. I just have one question. I'm going to go ahead and approve because I am good with your decision on the question either way, and even lean a bit toward the way it is now.

@@ -303,6 +303,14 @@ def clean_active_fedora_repository
Valkyrie::IndexingAdapter.find(adapter_name).wipe!
end

# Configure blacklight to use the valkyrie solr index
config.around(:example, index_adapter: :solr_index) do |example|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have this in place. It will help with future tests that need the valkyrie core to be primary.

@@ -0,0 +1,63 @@
# frozen_string_literal: true
RSpec.describe 'searching', index_adapter: :solr_index do
let(:user) { create :user }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First fully valkyrie feature test. 💯

@@ -50,6 +50,8 @@ attributes:
multiple: true
form:
primary: false
index_keys:
- "description_tesim"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- "description_tesim"
- "description_sim"
- "description_tesim"

Should this have the string version as well? It is pretty common to include both, but the string stores as the exact string typically used for exact matching. I don't imagine that someone would be looking for an exact match for the entire description.

String stores a word/sentence as an exact string without performing tokenization etc. Commonly useful for storing exact matches, e.g, for facetting.

Text typically performs tokenization, and secondary processing (such as lower-casing etc.). Useful for all scenarios when we want to match part of a sentence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell description was only every indexed as _tesim. (https://github.com/samvera/hyrax/blob/main/app/indexers/hyrax/basic_metadata_indexer.rb#L7)

@cjcolvar cjcolvar merged commit 4765c04 into main Mar 9, 2022
@cjcolvar cjcolvar deleted the pcdm_collection_search_results branch March 9, 2022 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Searches with collections in results are failing
2 participants