List a host's own planets ahead of the systems whose names only run on from its own

Once the archive's 3 277 hosts became stars and 574 Gaia hosts took their names, "K2-18" listed
the star K2-18 and then K2-180 to K2-186, and no planet: "k2-18 b" and "k2-180" were both prefix
matches, and on a tie the ranking put every star before every exoplanet. Replaying each host's
name through the ranking over the published catalogue, 325 hosts had some of their own planets
pushed out of the eight rows shown (655 planet rows), against 75 before the archive stars.

A prefix match that ends where a word does now scores 3.5, between an exact match and a prefix
running on into the same word. The same replay gives 50 hosts and 62 rows. In the running app
"K2-18" lists K2-18, K2-18 b, K2-18 c, then K2-180 onward; "Kepler-186" lists the star and
Kepler-186 b to f before Kepler-1860; Kepler-22 b and WASP-12 b are back. "Proxima", "Io" and
"TRAPPIST-1" list as before.

Control: scoring the word-ending prefix level with any prefix fails "lists a host's own planets
ahead of the systems whose names run on from its own" alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-30 16:05:08 +02:00
co-authored by Claude Opus 5.5
parent f8582b78d0
commit 2dac3767e8
2 changed files with 13 additions and 1 deletions
@@ -81,6 +81,11 @@ describe('rankSearchResults', () => {
expect(rank(entries, 'Proxima')[0]).toBe('Proxima Centauri'); expect(rank(entries, 'Proxima')[0]).toBe('Proxima Centauri');
}); });
it("lists a host's own planets ahead of the systems whose names run on from its own", () => {
const entries = [star('K2-18'), star('K2-180'), star('K2-181'), exoplanet('K2-18 b'), exoplanet('K2-18 c')];
expect(rank(entries, 'K2-18')).toEqual(['K2-18', 'K2-18 b', 'K2-18 c', 'K2-180', 'K2-181']);
});
it('breaks remaining ties by name length, then alphabetically', () => { it('breaks remaining ties by name length, then alphabetically', () => {
const entries = [exoplanet('Kepler-1292 b'), exoplanet('Kepler-9 c'), exoplanet('Kepler-9 b'), exoplanet('Kepler-15 b')]; const entries = [exoplanet('Kepler-1292 b'), exoplanet('Kepler-9 c'), exoplanet('Kepler-9 b'), exoplanet('Kepler-15 b')];
expect(rank(entries, 'Kepler')).toEqual(['Kepler-9 b', 'Kepler-9 c', 'Kepler-15 b', 'Kepler-1292 b']); expect(rank(entries, 'Kepler')).toEqual(['Kepler-9 b', 'Kepler-9 c', 'Kepler-15 b', 'Kepler-1292 b']);
+8 -1
View File
@@ -28,6 +28,13 @@ export function entrySubtitle(entry: SearchEntry): string {
* prefix match, and so on, so a better kind of match can never be crowded out by a worse one. * prefix match, and so on, so a better kind of match can never be crowded out by a worse one.
*/ */
const MATCH_EXACT = 4; const MATCH_EXACT = 4;
/**
* A prefix that ends where a word does, "kepler-186 f" for "kepler-186", ahead of one running on into
* the same word, "kepler-1860". Level with it, the star outranked the planet on kind, and once the
* archive's hosts became stars, searching a host's name listed K2-180 to K2-186 and none of K2-18's
* planets: 325 hosts lost some of their own planets from the eight rows shown, and now 50 do.
*/
const MATCH_WORD_PREFIX = 3.5;
const MATCH_PREFIX = 3; const MATCH_PREFIX = 3;
const MATCH_WORD_START = 2; const MATCH_WORD_START = 2;
const MATCH_SUBSTRING = 1; const MATCH_SUBSTRING = 1;
@@ -89,7 +96,7 @@ function scoreIndexed(indexed: IndexedSearchEntry, normalizedQuery: string, comp
return MATCH_EXACT; return MATCH_EXACT;
} }
if (indexed.normalizedName.startsWith(normalizedQuery)) { if (indexed.normalizedName.startsWith(normalizedQuery)) {
return MATCH_PREFIX; return WORD_SEPARATORS.test(indexed.normalizedName.charAt(normalizedQuery.length)) ? MATCH_WORD_PREFIX : MATCH_PREFIX;
} }
if (indexed.words.some((word) => word.startsWith(normalizedQuery))) { if (indexed.words.some((word) => word.startsWith(normalizedQuery))) {
return MATCH_WORD_START; return MATCH_WORD_START;