bhabegger commented on code in PR #3079:
URL: https://github.com/apache/jackrabbit-oak/pull/3079#discussion_r3804095914
##########
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticDynamicBoostTest.java:
##########
@@ -85,6 +87,63 @@ public void dynamicBoostAnalyzed() throws Exception {
});
}
+ @After
+ public void resetDynamicBoostGroupingToggle() {
+ ElasticDocument.FT_OAK_12353_ENABLE.set(true);
+ }
+
+ /**
+ * Predicted tags sharing the same boost score are grouped into a single
nested document
+ * (see {@link ElasticDocument#FT_OAK_12353_ENABLE}). This verifies that
querying still
+ * matches on any of the grouped values, both with the grouping enabled
(default) and
+ * disabled.
+ */
Review Comment:
I would even try to write the test in such a way that the body of the test
with and without the toggle is shared making it straight forward.
```
@Test
void ungroupedDynamicBoostedQueriesWork() {
// Given
ElasticDocument.FT_OAK_12353_ENABLE.set(false);
// Then
assertSimpleBoostedQueriesWork();
}
@Test
void groupedDynamicBoostedQueriesWork() {
// Given
ElasticDocument.FT_OAK_12353_ENABLE.set(true); // <- explicit intent
// Then
assertSimpleBoostedQueriesWork();
}
void assertSimpleBoostedQueriesWork() {
Tree testParent = createNodeWithType(root.getTree("/"), "test",
JcrConstants.NT_UNSTRUCTURED, "");
Tree predicted1 = createAssetNodeWithPredicted(testParent, "asset1",
"flower with a lot of red and a bit of blue");
createPredictedTag(predicted1, "red", 5.0);
createPredictedTag(predicted1, "blue", 5.0);
createPredictedTag(predicted1, "green", 5.0);
createPredictedTag(predicted1, "special", 9.0);
root.commit();
assertEventually(() -> {
assertQuery("//element(*, dam:Asset)[jcr:contains(., 'red')]",
XPATH, List.of("/test/asset1"));
assertQuery("//element(*, dam:Asset)[jcr:contains(., 'blue')]",
XPATH, List.of("/test/asset1"));
assertQuery("//element(*, dam:Asset)[jcr:contains(., 'green')]",
XPATH, List.of("/test/asset1"));
assertQuery("//element(*, dam:Asset)[jcr:contains(.,
'special')]", XPATH, List.of("/test/asset1"));
});
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]