Service - Complex Filter
Jump to navigation
Jump to search
Overview
Allows for filters that span nested levels of related entities
Repository
https://bitbucket.org/stb_working/complex-filter/src/master/
DynamoDB tables
Standard Config Table Per Service
Configuration tags
{
configKey: "FilterType"
configTag: "xx" // eg: variant / product / sellOffer
configValue: {
childComplexFilterTypes: {
{child filterType}: {
"translateIdsServiceName": "xx" // eg: variantManager / sellOfferManager, service than converts child id to parent id
},
},
logicalServiceNames : ["xx", "yy"] // eg: "ProductStandard", "ProductCustom"
}
}
- logicalServiceNames should not duplicate over mulitiple FilterType's, because we use this setting to match a Logical Service response to a FilterMain record, need it to uniquely identify one filterMain record
{
configKey: "ComplexFilterServiceName"
configTag: "xx" // eg: product / sellOffer
configValue: "yy" // eg: ComplexFilterProducts
}
{
configKey: "ExpiryInterval"
configTag: "ExpiryInterval"
configValue: xx // minutes(?) complexfilter ttl
}
{
configKey: "MaxProcessInvocationCount"
configTag: "MaxProcessInvocationCount"
configValue: 10 // maximum number of invocations allowed for large operation complex filter processing
}
complexFilter request
{
filterType: "xx" // eg: "mediaLink",
type: "group",
elements:
[
{
type: "complexFilter",
complexFilter: {
filterType: "xx", //eg: mediaLinkProperty
type: "group",
elements:
[
{
type: "logical",
logicalTag: "propertyLabelId", // is used by the logical service/s to decide how to find data
// the below properties are up to the logicalTag what is needed, but these are common:
comparison: "equals",
value: "lksdflkfldfgldfkgjldfg"
},
]
}
},
{
type: "logicalOperator",
operator: "and"
},
{
type: "complexFilter",
complexFilter: {
filterType: "xx", //eg: mediaLinkPropertyTranslation
type: "group",
elements:
[
{
type: "logical",
logicalTag: "textTag_languageId_text",
//example for matching to specific translation text:
textTag: "mediaLinkPropertyValue",
languageId: "en",
text: "Blue",
subjectIdentifierPropertyName: "propertyId",
caseSensitive: true
},
]
}
},
...
]
}
How to request Complex Filter
- invoke shared library function createFilterMainId which iterates through elements and builds filterMainId by applying operators. There are no database requests in this function so it can be run from any service and can trust the filterMainId will be standardized
- No cleaning of the filter object is performed, so additional unused properties would result in a different filterMainId, even if the underlying filter is the same
- calling function saves filterMainId in pending table waiting for filter complete, this needs to be done before calling ProcessComplexFilter to protect against race condition of complex filter completing before pending record saved (probably use AwaitingStep process)
- All requests to ProcessComplexFilter will send a message out, even if cache exists
- CallingFlow param allows Complex Filter service to pass a message back to only the calling flow when a request hits cached results
How is filterMainId generated
- cannot hash entire request elements without iterating through the elements because a final filterMainId of multiple elements is actually the final operation filterMainId (hash of the last element joined with the previous culmination of operation elements)
- this does not match a hash of the original request object
- needs to be done this way so we can back track through parent operations in a standardized way when receiving results for each element