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

Replace "Linked Agent By Role" - new Plugin for filtering Typed Relations in search API #89

Merged
merged 8 commits into from
Mar 16, 2024

Conversation

rosiel
Copy link
Member

@rosiel rosiel commented Nov 23, 2022

What does this Pull Request do?

Creates new "fields" (in search api) for your Typed Relation fields. You can filter what relation types get included.

This does the same thing as the Linked Agent By Role plugin on the Islandora Install Profile Demo, except without the hard-coding and without cluttering the Search API field with 271 different fields.

What's new?

New Search API Processor plugin!

  • Creates a new field (under "general" - FIXME!!) for each configured Typed Relation field. For example there is one for "Linked Agent [islandora_object]"
  • When you select this field, it lets you choose one or more "Relation Types" from the list that is currently configured for that field.

Selecting the new field

Configuring the new field

  • Does this change require documentation to be updated? Sure!
  • Does this change add any new dependencies? no!
  • Does this change require any other modifications to be made to the repository
    (i.e. Regeneration activity, etc.)? nah.
  • Could this change impact execution of existing code? no.

How should this be tested?

A description of what steps someone could take to:

  • Reproduce the problem you are fixing (if applicable)
  • Test that the Pull Request does what is intended.
  • Please be as detailed as possible.
  • Good testing instructions help get your PR completed faster.

Additional Notes:

Any additional information that you think would be helpful when reviewing this
PR.

Interested parties

Tag (@ mention) interested parties or, if unsure, @Islandora/committers

@rosiel
Copy link
Member Author

rosiel commented Nov 23, 2022

Can be tested, feedback welcome.

I'm going to try to move these fields out of search api's "General" section, and into the individual sections for "Content", "Media", etc.

@rosiel rosiel marked this pull request as ready for review November 24, 2022 13:57
@rosiel
Copy link
Member Author

rosiel commented Nov 24, 2022

With the last commit, the fields no longer show in "General" but in the appropriate "datasource" (i.e. Content, Taxonomy Term, etc... they show up with their partner fields.)

If you already had started testing before this commit, you need to remove existing fields of this type, and clear the index and "rebuild tracking information". I had trouble because it had cached the old (invalid) field definition.

Screen Shot 2022-11-23 at 10 00 22 PM

src/Plugin/search_api/processor/TypedRelationFiltered.php Outdated Show resolved Hide resolved
src/Plugin/search_api/processor/TypedRelationFiltered.php Outdated Show resolved Hide resolved
src/Plugin/search_api/processor/TypedRelationFiltered.php Outdated Show resolved Hide resolved
->filterForPropertyPath($search_api_fields, $item->getDatasourceId(), $property_path);
foreach ($search_api_fields as $search_api_field) {
// Load entity's field values.
$vals = $content_entity->$field_name->getValue();
Copy link
Member

Choose a reason for hiding this comment

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

Should be able to use referencedEntities here without the need to load up things I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

I need the rel_type, i'm not sure that would be in the referenced entities list.

@simonhm
Copy link

simonhm commented Jan 24, 2023

@rosiel
We're testing this patch, and unfortunately this's not working as intended.
After patching this PR, new search API processor is showed up. I enabled it and was able to add new field Linked Agent (filtered by type) as same as your instruction.
Then when I re-index, I got the below messages in Recent Logs:

Notice: Undefined index: bundle in Drupal\controlled_access_terms\Plugin\search_api\processor\TypedRelationFiltered->addFieldValues() (line 137 of /var/www/html/drupal/web/modules/contrib/controlled_access_terms/src/Plugin/search_api/processor/TypedRelationFiltered.php) #0 /var/www/html/drupal/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8, 'Undefined index...', '/var/www/html/d...', 137) #1 /var/www/html/drupal/web/modules/contrib/controlled_access_terms/src/Plugin/search_api/processor/TypedRelationFiltered.php(137): _drupal_error_handler(8, 'Undefined index...', '/var/www/html/d...', 137, Array) ...

And the facet for this new field is not displaying/working as intended after I do a search.
Simon.

@rosiel
Copy link
Member Author

rosiel commented Jan 27, 2023

Thank you so much! I think I've fixed that now.

@jordandukart jordandukart self-assigned this Feb 1, 2023
@jordandukart
Copy link
Member

Configuration schema changes here are the same as in Islandora/islandora#913 (comment). I think we may be able to re-work how these are constructed. I may give this a go and update this further.

@seth-shaw-asu
Copy link
Member

@jordandukart, were you able to re-work the configuration schema changes as mentioned in #89 (comment), or should we move forward with testing and merging?

@wgilling
Copy link
Contributor

I will add "review this" PR to my to-do list for this week sometime.

@wgilling
Copy link
Contributor

I must have something in my local "bd-isle" project that is interfering with seeing these. Would I be able to see the "Linked Agent (filtered by type) [islandora] typed_relation_filter__node__islandora_object_field_linked_agent" on the Solr index | Fields page https://islandora.traefik.me/admin/config/search/search-api/index/default_solr_index/fields?

image

@rosiel
Copy link
Member Author

rosiel commented Aug 23, 2023

You might have to enable it first, under the "Processors" tab.

@wgilling
Copy link
Contributor

Linked Agent by Type "adds the item's linked agent separately by type" was checked. This is probably conflicting with something in the bd-isle flavor site I pulled this feature branch of controlled access terms into. How do I spin up a vanilla islandora site?

@aOelschlager aOelschlager self-requested a review February 28, 2024 19:49
Copy link
Contributor

@ajstanley ajstanley left a comment

Choose a reason for hiding this comment

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

Once the processor has been added, the new form shows up where it should. Tested with Contributor, and an arbitrary new field.

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.

6 participants