I'm trying to read some DOM instances based on some conditions but I'm getting an exception.
These are the conditions:
var resourceDomGuids = resourcesData.Keys.ToList();
// Get jobs using nodes that have have certain dim id in the reference
var searchQueryJobs = resourceDomGuids.Select(resourceDomId =>
DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflow.Sections.Nodes.NodeReferenceID)
.Equal(resourceDomId)).ToArray();
var orFilterJobs = new ORFilterElement<DomInstance>(searchQueryJobs);
// Only jobs in the future and within 4 hours
var timeFilterStart = DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflow.Sections.JobInfo.JobStart).GreaterThan(DateTime.UtcNow);
var timeFilterEnd = DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflow.Sections.JobInfo.JobStart).LessThan(DateTime.UtcNow.AddHours(4));
var andTimeFilter = new ANDFilterElement<DomInstance>(timeFilterStart, timeFilterEnd);
// Only jobs in confirmed or canceled state
var confirmedFilter = DomInstanceExposers.StatusId.Equal(SlcWorkflow.Behaviors.Job_Behavior.Statuses.Confirmed);
var canceledFilter = DomInstanceExposers.StatusId.Equal(SlcWorkflow.Behaviors.Job_Behavior.Statuses.Canceled);
var orFilterState = new ORFilterElement<DomInstance>(confirmedFilter, canceledFilter);
// Definition filter
var definitionFilterJobs = DomInstanceExposers.DomDefinitionId.Equal(SlcWorkflow.Definitions.Jobs.Id);
My goal is that this query works:
// Query
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, andTimeFilter, orFilterState);
var domInstanceJobs = domHelperWorkflow.DomInstances.Read(andFilterJobs);
But i can only make it to work like this:
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs);
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, confirmedFilter);
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, timeFilterStart);
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, confirmedFilter, timeFilterStart);
If I introduce another condition for the state or the time it fails.
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, timeFilterStart, timeFilterEnd);
Hi Daniel,
As mentioned in Tom's comment, could you share the exception you are getting? This will help us to understand what could be going wrong.
When I check the query you shared, I already have a slight assumption it may be caused by the amount of clauses it has. On the Elasticsearch and OpenSearch database, there is a limit on the amount of clauses a single query can have. In your query, this amount seems to be variable depending on the amount of IDs in the 'resourceDomGuids' variable. Could you check and share how many IDs are in there?
Hi Daniel, what exception do you get?