ADR: Ability to get all the records of a given Persisted Collection from search
Status
-
Proposed -
Trialing -
Under review -
Approved -
Retired
Context & Scope
A persisted collection can aggregate objects of different nature including master data, work-product-component, reference data. It could contain collection of records of heterogenous kind. At a given point, MemberIDs field of PersistedCollection maintains list of objects which are part of the collection.
More can be read from this schema .
Problem :
Today, there is no way to get all the records which belongs to a particular Persisted Collection. Today, user has to perform atleast 2 search queries to get the records of a Persisted Collection.
1st Query - To get the Persisted Collection record and retrieve record IDs are from MemeberID field.
2nd Query - To get the actual record from retrieved record Ids in the 1st query.
For the 2nd query, to get multiple records in 1 search query, user has to form a query with OR operator. E.g.
{
"Query" : recordId-1 OR recordId-2 OR recordId-3 .. recordId-1000.
}
Here ElasticSearch has limitation of max usage of OR conditions in 1 query.
So if a PersistedCollection contains more than 1000 records , user has to invoke multiple search queries to get all the records.
Possible Solution
One of the possible solution to address this requirement could be adding Persisted Collection record id in the record's data. So whenever records get added to the Persisted Collection , record's data should be updated with the information of Persisted Collection id.
This could be done by listening to record change event for PersistedCollection kind .
Consequences
- This will help users to get the records of Persisted Collection in a single go.
- This will help users to get the records to which he/she has access.
- This will help users to form queries to get desire records from PeristedCollection such as “Give all the records of a persisted collection where data.<someproperty> is <xyz>“ in one go.
- This will help users to make filters based on different objects in the collection.