activity stream sorting filtering added to regular sorting filtering of entities in modern drupal 10 search api

My self-answering posts in Drupal’s Search Slack channel:

Say i have a multipart field (only example in core i know of is say body:value and body:format) and i filter by one part, can i then sort by the corresponding part? 2 replies

mlncn 1 minute ago Pretty sure we will need to do something other than a multivalue, multipart field to get what we need. Here is the full context, trying to add activitystream style capabilities to a faceted search. So show “My recent activity” and have facets for entity type, bundle, and tag etc as usual but also be restricting what is shown to things i have interacted with by creating, editing, annotating (not (yet?) comments, don’t ask). If i created something a year ago and someone edited it today, i wouldn’t see that. But if something that was last edited a year ago (by anyone) but i edited an annotation on it today, that would show up. Was originally thinking we have a field with these three ‘subfields’:

mlncn < 1 minute ago On further thought, the above approach would never work. (Correct me if i’m wrong!) Activity stream needs to be its own base table / entity, because Search API is not going to want to show the entity i created, edited, and annotated three times separated by all the other activities anyway.

Zulip thread: sorting/filtering by most recent activity

mlncn: @wolcen what was your initial vision for this? I think we do want it on a field that we add to all content we want to filter that way. But then the field itself needs to be filtered… i think Drupal/Views/Search API/Solr can do that…

three-part multivalue field:

user (id), activity type (string), datetime

the user we care about won’t necessarily be in the 0th position of that multivalue field, is the part i need to test, but wondering if you had a cleverer plan, working from a good database join on up

wolcen: umm…

wolcen: the whole concept of “add a field” is confusing to me (damn Drupal) but I think I follow how that could work.

wolcen: and when you say multi-value field, is that from the concept of a Drupal custom field type that is merely a pre-defined container with three “actual” field values in it (i.e. a Drupal high-level struct, sort of)


multivalue Drupal triplet structure, each user, activity type, datetime set will exist multiple times on each piece of content

pretty sure we will need to do something other than a multivalue, multipart field.

Say we have a field with these three ‘subfields’:

I can filter to only show articles that have a user in activities, but i cannot then use the activities:date corresponding to that activities:user to do the sort, or the corresponding description to display.

From Chris:

e.g. given:

nid type activities:user activities:description activities:date
1 blog 1 inserted 1/1/2024
1 blog 2 comment 1/2/2024
1 blog 1 updated 1/5/2024
2 blog 1 inserted 1/1/2024
2 blog 1 updated 1/5/2024

desired outputs

overall activity: admin inserted blog 1 on 1/1/2024 admin inserted blog 2 on 1/1/2024 user commented on blog 1 on 1/2/2024 admin updated blog 1 on 1/5/2024 admin updated 2 on 1/5/2024

or for a single user (admin): inserted blog 1 on 1/1/2024 inserted blog 2 on 1/1/2024 updated blog 1 on 1/5/2024 updated 2 on 1/5/2024

or for a single user (user): commented on blog 2 on 1/2/2024