diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java index d23f38cf85b..b418a6a16fd 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java @@ -13,6 +13,7 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; +import static uk.gov.hmcts.reform.civil.enums.CaseState.HEARING_READINESS; import static uk.gov.hmcts.reform.civil.enums.CaseState.PREPARE_FOR_HEARING_CONDUCT_HEARING; @Service @@ -30,7 +31,10 @@ public Query query(int startIndex) { .must(rangeQuery("data.hearingDate").lt(LocalDate.now() .atTime(LocalTime.MIN).plusWeeks(3) .toString())) - .must(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING)) + .must(boolQuery() + .minimumShouldMatch(1) + .should(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING)) + .should(beState(HEARING_READINESS))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.trialReadyChecked", "Yes"))), List.of("reference"), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java index 878b2f73638..53a26cd55e1 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java @@ -15,6 +15,7 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; +import static uk.gov.hmcts.reform.civil.enums.CaseState.HEARING_READINESS; import static uk.gov.hmcts.reform.civil.enums.CaseState.PREPARE_FOR_HEARING_CONDUCT_HEARING; @Service @@ -32,10 +33,13 @@ public Query query(int startIndex) { .must(rangeQuery("data.hearingDate").lt(LocalDate.now() .atTime(LocalTime.MIN) .plusWeeks(6).toString())) - .must(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING))) + .must(boolQuery() + .minimumShouldMatch(1) + .should(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING)) + .should(beState(HEARING_READINESS))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.listingOrRelisting", ListingOrRelisting.RELISTING)) - .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES)), + .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES))), List.of("reference"), startIndex ); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java index 0aefcb6a5c2..24a6e6b3716 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java @@ -26,7 +26,10 @@ protected Query buildQuery(int fromValue) { .should(boolQuery() .must(rangeQuery("data.hearingDate").lt(LocalDate.now().atTime(LocalTime.MIN).plusWeeks(3) .toString())) - .must(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING"))) + .must(boolQuery() + .minimumShouldMatch(1) + .should(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING"))) + .should(boolQuery().must(matchQuery("state", "HEARING_READINESS")))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.trialReadyChecked", "Yes"))); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java index 961b2c67253..f94d49c3430 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java @@ -28,10 +28,13 @@ protected Query buildQuery(int fromValue) { .should(boolQuery() .must(rangeQuery("data.hearingDate").lt(LocalDate.now().atTime(LocalTime.MIN).plusWeeks(6) .toString())) - .must(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING")))) + .must(boolQuery() + .minimumShouldMatch(1) + .should(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING"))) + .should(boolQuery().must(matchQuery("state", "HEARING_READINESS")))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.listingOrRelisting", ListingOrRelisting.RELISTING)) - .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES)); + .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES))); return new Query(query, List.of("reference"), fromValue); }