Repository navigation
Rank an API operation first when the query is its whole title - #4908
Conversation
Several tuned behaviours lived only in the `ApiLookupWeights` comments: the current `HEAD /_template/{name}` above its deprecated twins, the endpoint isolate pair, and a landing page leading for the words of its name. Eight judged cases and one landing test now pin them, so a weight change that moves one fails a test.
The explicit `ApiSearchRelevanceReport` also lists queries with no expected result and writes its output to `API_SEARCH_REPORT_PATH`, so a run before and a run after a change can be diffed.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`create index` lists "Create a new document in the index" first and "Create an index" eighth. The `_create` endpoint scores 6.0 for the word `create`, while `PUT /{index}` has no endpoint key. `delete index` has the same shape with "Delete indices". The cases fail on the dev index until the next commit.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`create index` listed "Create an index" eighth because the one stopword in the title switched off the only exact-title signal, and the `_create` endpoint of a document scored 6.0 for the word `create` alone. `delete index` had the same shape with "Delete indices". Each operation now indexes its title as `api.title_fingerprint`, one token of its stemmed content words in sorted order. A query made of those words, in any order, with or without stopwords and plurals, matches it and earns `ApiLookupWeights.TitleNamed` (6.0). The lift replaces the unbounded exact-title `term` on `title.keyword`, which an index without the new field keeps through the same `dis_max`. Measured on the dev index after a rollover: `create index` and `index create` lead at 13.13 against 11.20, `delete index` at 13.13 against 8.08, and the judged cases pass. `run a search` drops 2.1 points and keeps its order. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Four doc comments restated what the code beside them already shows. Each now keeps only the reason a reader cannot see, such as why the `match` takes no analyzer. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| // One token per text: its stemmed content words, sorted and joined. "Create an index", "create index" and | ||
| // "index create" all become "create index", so a query matches a title that has the same words in any order. | ||
| .Analyzer( | ||
| SharedMappingConfig.TitleFingerprintAnalyzer, | ||
| a => a | ||
| .Custom() | ||
| .Tokenizer("standard") | ||
| .Filters("lowercase", "english_stop", "title_fingerprint_stem_filter", "kstem", "fingerprint") | ||
| ) | ||
| // kstem keeps "indices" apart from "index", which would leave "Delete indices" unreachable for "delete index". | ||
| .TokenFilter("title_fingerprint_stem_filter", tf => tf.StemmerOverride().Rules("indices => index")) |
There was a problem hiding this comment.
Severity: P3 (Low)
No CI test covers title_fingerprint_analyzer or title_fingerprint_stem_filter. The fix depends on the exact filter chain: english_stop must drop "an", the indices => index override must run before kstem, and fingerprint must come last. Only the integration relevance cases exercise this, and the PR notes those don't run in CI. If someone reorders the filters or drops the override, delete index or create index would regress without anything failing. Please add a case to the existing tests/Elastic.SiteSearch.Tests/SharedAnalysisFactoryTests.cs that asserts the analyzer's filter order and the override rule.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4908/ Sample changed pages: |
API search now ranks an operation first when the typed words are its whole title, whatever their order and without the title's stopwords or plurals.
create indexfinds "Create an index" first, where it used to list it eighth.Affects: Search, API reference
Prompt summary: Fix the API search result for
create index, where the "Create an index" operation sat seventh and showed only after scrolling. Then make sure the ranking work done earlier keeps working, with tests that fail when a later change moves it.Why
create indexlists "Create a new document in the index" first and "Create an index" eighth. The wordcreateis the_createendpoint of the document operation, which scores 6.0 on its own, whilePUT /{index}has no endpoint key. The only whole-title signal is an exact match ontitle.keyword, and the "an" in the title defeats it.delete indexhas the same shape: "Delete indices" lists twelfth.What
A title that matches by its words
Each operation indexes its title as
api.title_fingerprint, one token of the title's stemmed content words in sorted order. A query made of those words earns a 6.0title_namedlift. The lift replaces the exact-titleterm, which stays as the first option of the samedis_max, so an index without the new field keeps matching exact titles.The analyzer behind it
title_fingerprint_analyzerrunsstandard,lowercase,english_stop, a stemmer override forindices => index,kstemandfingerprint. It sits in the shared base analysis next to the other analyzers some document types do not use. The override is private to this analyzer, so docs-wide search does not change.Judged cases that lock earlier tuning
Eight judged cases and a landing-page test pin behaviour that lived only in
ApiLookupWeightscomments, such as the currentHEAD /_template/{name}above its deprecated twins. They pass on the code before this fix. The failingcreate index,index createanddelete indexcases land in their own commit, ahead of the fix.A report you can diff
The explicit
ApiSearchRelevanceReportnow also lists queries with no expected result and writes its output toAPI_SEARCH_REPORT_PATH. A run before and a run after a change can be diffed.Verify
Measured on the dev index after a rollover:
create indexoperation-createfirst, 11.20delete indexThe controls
search knn,cluster health,snapshot restoreandget cluster settingskeep their order and margins. Across 82 queries the top three changed mostly through Stack and Serverless ties, plus gains such asreassign agent.run a searchloses 2.1 points and keeps its order.The integration cases are not run in CI, because the
integrationjob inci.ymlis disabled. One case,ApiSearchPlainWordDoesNotCoverTheRoutesUnderItsOwnName, also fails onmainwith Kibana results forapi key.Risk: The field is new on every API document, so the next indexing run changes every API document hash and rolls the index over to the new mapping. Until an environment's index rolls over,
create indexbehaves as before.Out of scope:
get indexstill listsget-index-templatefirst because its title is "Get index information", andcreate index templatestill leads with a deprecated operation.🤖 Generated with Claude Code