Local search ranks literal identifier matches by title, not by how often the term appears

Aperta Adatta ai principianti
#60 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
hugo, javascript
Ambito
search

Direzione di ricerca

Inizia in assets/js/search-engine.js, dove le query di identificatori letterali vengono valutate e confrontate. Usa la riproduzione Node inclusa per confermare l’ordinamento attuale. Poi verifica che, tra le pagine che corrispondono nello stesso campo, un maggior numero di occorrenze comporti un posizionamento più alto, mentre l’ordine dei titoli rimanga un criterio per risolvere le parità. Esegui di nuovo la riproduzione e conferma che Query reference appare prima di Alpha notes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: v1.5.0 (84b93e4)

What happens

A query that contains _, . or - (for example top_k) skips Lunr and is matched literally in assets/js/search-engine.js. A page's score for the term is the weight of the highest field that contains it (title 100, keywords 80, headings 50, body 10), with no count of occurrences. Pages that mention the identifier only in body text all score 10, and compare() then orders them by title. A page that mentions the term once in passing ranks above the page that documents it.

On a 45-page docs site, top_k appears in the body of 15 pages, and the top five results are the first five titles in alphabetical order. The pages that define the parameter come later. With v1.1.0 the same query went through Lunr and ranked those pages first.

Minimal reproduction (no site build needed)

// node repro.cjs path/to/oink/assets/js/search-engine.js
global.window = {};
const engine = require(process.argv[2]);
const docs = [
  { ref: '/a/', title: 'Alpha notes', body: 'Benchmarks ran with top_k set to 10.' },
  { ref: '/q/', title: 'Query reference',
    body: 'top_k: number of results. Set top_k to 5 for short answers. top_k must be ' +
          'between 1 and 100. When top_k exceeds the candidate pool, fewer results return.' },
];
console.log(engine.create(docs, null, 10).query('top_k').map((r) => r.doc.title));

Output: [ 'Alpha notes', 'Query reference' ]. Renaming "Alpha notes" to "Zulu notes" reverses the order, so the title is the tie-breaker.

Expected

Among pages that match in the same field, the page where the term occurs more often ranks higher.

Possible direction

Add an occurrence count within a field tier, for example weight + min(count, 10), before falling back to the title order. search_keywords works as a per-page workaround today.

Lingua principale
HTML
Stelle
148
Fork
17
Merge medio
1g 11h
PR unite (30g)
9

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su Search

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.