Croway commented on code in PR #27814:
URL: https://github.com/apache/camel/pull/27814#discussion_r4271699754
##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/MigrationData.java:
##########
@@ -283,87 +290,319 @@ private static String getElementText(Element parent,
String tagName) {
private static final String GUIDES_RESOURCE_DIR = "migration-guides/";
private static final String GUIDES_INDEX_FILE = GUIDES_RESOURCE_DIR +
"index.txt";
- private volatile List<GuideSection> guideIndex;
+ /**
+ * Words dropped from search queries: they appear in nearly every
migration guide entry (camel, migration, upgrade,
+ * version, guide) or carry no meaning on their own (to, from, the, ...),
so they only add noise to the ranking.
+ */
+ static final Set<String> STOP_WORDS = Set.of(
+ "camel", "apache", "migration", "migrate", "migrating", "upgrade",
"upgrading", "upgraded", "version",
+ "versions", "guide", "guides", "release", "change", "changes",
"changed",
+ "a", "an", "and", "are", "as", "at", "be", "by", "do", "does",
"for", "from", "how", "in", "is", "it", "my",
+ "of", "on", "or", "the", "this", "to", "what", "when", "which",
"with");
+
+ /** BM25 term frequency saturation. */
+ private static final double BM25_K1 = 1.2;
+ /** BM25 length normalisation: 0 ignores the entry length, 1 fully
normalises by it. */
+ private static final double BM25_B = 0.5;
+ /** Extra weight, in units of the term idf, when a query term appears in
the entry heading. */
+ private static final double TITLE_BOOST = 1.5;
+ /** Weight of a part of an unknown hyphenated query term, e.g. http4 for
camel-http4. */
+ private static final double PART_WEIGHT = 0.7;
+ /** Weight of a vocabulary term matched by Levenshtein distance instead of
exactly (typo tolerance). */
+ private static final double FUZZY_WEIGHT = 0.7;
+ /** Weight of a vocabulary term that only contains the query term as a
substring. */
+ private static final double SUBSTRING_WEIGHT = 0.3;
+ /** Multiplier when the whole query appears verbatim in the entry. */
+ private static final double PHRASE_BOOST = 1.25;
+ /**
+ * Multiplier for the entries of the 2.x to 3.0 and 3.x to 4.0 migration
guides in a version-scoped search, so they
+ * rank above comparable upgrade guide entries without pushing out strong
ones.
+ */
+ static final double MAJOR_GUIDE_BOOST = 1.85;
Review Comment:
Done in 30580f72ed3c: the factor is 1.5 and
`versionRangeFavoursMajorMigrationGuides` asserts that the 2.x-to-3.0
"Migrating Camel applications" entry is among the hits (with the camel-cxf
content), not that it is first. `versionRangeKeepsStrongUpgradeGuideEntries`
still checks the camel-cxf upgrade entries stay in the top 3.
_Claude Code on behalf of Croway_
--
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]