From c37cfb05d7681a2b29b70be44e4d9e7beeb684fd Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 7 Jun 2024 12:24:25 +0200 Subject: Test that diversity requires either match-phase or second-phase --- .../java/com/yahoo/schema/DiversityTestCase.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'config-model/src/test/java') diff --git a/config-model/src/test/java/com/yahoo/schema/DiversityTestCase.java b/config-model/src/test/java/com/yahoo/schema/DiversityTestCase.java index 4026341464f..d9355e2df7d 100644 --- a/config-model/src/test/java/com/yahoo/schema/DiversityTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/DiversityTestCase.java @@ -79,6 +79,29 @@ public class DiversityTestCase { } } + @Test + void requireMatchPhaseOrSecondPhase() throws ParseException { + ApplicationBuilder builder = new ApplicationBuilder(new RankProfileRegistry()); + builder.addSchema(""" + search test { + document test { + field b type int { indexing: attribute } + } + rank-profile parent { + diversity { + attribute: b + min-groups: 74 + } + } + }"""); + try { + builder.build(true); + fail("Should throw."); + } catch (IllegalArgumentException e) { + assertEquals("In schema 'test', rank-profile 'parent': 'diversity' requires either 'match-phase' or 'second-phase' to be specified.", e.getMessage()); + } + } + private static String getMessagePrefix() { return "In search definition 'test', rank-profile 'parent': diversity attribute 'b' "; } -- cgit v1.2.3