Incorrect grouping of search results between "Extensions" and "Other Matches"
Nessuno ha ancora preso questa issue.
- Lingua principale
- PHP
- Stelle
- 1.1k
- Fork
- 640
- Merge medio
- 22h 36m
- PR unite (30g)
- 16
Descrizione
Background
In https://github.com/php/phd/pull/154, we resolved the issue of missing pages in the search index. However, now that these pages are visible in search results, a long-standing bug in result grouping has become apparent.
Issue
Some search results are incorrectly categorized between the "Extensions" and "Other Matches" groups.
Example:
Query: security
As shown:
- "Security (PHP Manual)" appears in the "Extensions" group, although it is not a PHP extension.
- "Security consideration" (from the
win32serviceextension) is incorrectly placed in the "Other Matches" group.
Cause
The client-side search code groups results based on types, including Function, Variable, Class, Exception, Extension, and Other Matches (general). These types are assigned according to the XML element tags in the manual's source.
Issue 1: Incorrect grouping in "Extensions"
The first issue occurs in this section of the code:
https://github.com/php/web-php/blob/27fbef13e912547b4086793a5dd2e04fc0fcf684/js/search.js#L130-L134
The code assumes that any entry with the element tag <book>, <set>, or <reference> is related to extensions, which is inaccurate. Many entries, though using these elements, do not belong to extensions.
Example data:
| id | ldesc | element |
|---|---|---|
| getting-started | Getting Started | book |
| install | Installation and Configuration | book |
| ... | ... | ... |
| reserved.variables | Predefined Variables | reference |
| wrappers | Supported Protocols and Wrappers | reference |
| ... | ... | ... |
SELECT "docbook_id", "ldesc", "element"
FROM "ids"
WHERE "element" IN ('book','set','reference')
Issue 2: Incorrect grouping in "Other Matches"
The second issue is due to an assumption in the following code:
https://github.com/php/web-php/blob/27fbef13e912547b4086793a5dd2e04fc0fcf684/js/search.js#L136-L141
The code assumes that entries with the tags <section>, <chapter>, <appendix>, or <article> do not belong to an extension. While this is not as bad, there are many pages that are part of an extension but are currently placed in the "Other Matches" group:
| id | ldesc | element |
|---|---|---|
| ... | ... | ... |
| apcu.installation | Installation | section |
| apcu.configuration | Runtime Configuration | section |
| ... | ... | ... |
| pdo.setup | Installing/Configuring | chapter |
| pdo.constants | Predefined Constants | appendix |
| pdo.connections | Connections and Connection management | chapter |
| ... | ... | ... |
SELECT "docbook_id", "ldesc", "element"
FROM "ids"
WHERE "element" IN ('section','chapter','appendix','article')
PHP Manual index dump
For convenience, here is the dump from the PHD SQLite index for the PHP Manual: php-manual-index_2024-10-08.sql.gz
Notes
- This will continue to be relevant even after #1084 is merged, as it uses the same logic for displaying the result type.
- The screenshot has the upcoming fix for https://github.com/php/phd/issues/159 applied.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in js/search.js, nella logica di raggruppamento intorno alle righe 130-141, quindi confronta le relative ipotesi basate sugli elementi con il PHP Manual SQLite index dump fornito e con gli esempi elencati. Determina come il tipo di risultato debba distinguere le pagine delle estensioni dalle pagine generali del manuale e verifica che i risultati Security, apcu, pdo e simili compaiano nei gruppi corretti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, php
- Ambito
- frontend, search
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100