Search with a quoted phrase plus other words returns the whole catalog

Aperta Adatta ai principianti
#6,567 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
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
search

Direzione di ricerca

L’issue indica app/search/queries/registry.py e menziona parse_search_query, build_base_query e gli unit test da aggiungere. Leggi prima build_base_query e i test di query esistenti. Il lavoro è completato quando le ricerche con una frase e una parola, e quelle con due frasi, richiedono che corrispondano tutti i termini, mentre una frase senza corrispondenze non restituisce risultati.

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

Descrizione

bug

A catalog search that combines a quoted phrase with plain words, without OR, ignores the search and returns the whole catalog sorted by popularity.

  • Environment: prod catalog.data.gov
  • Component: datagov-catalog search, app/search/queries/registry.py

How to reproduce

  1. Search https://catalog.data.gov/search?q=%22baby%20names%22%20california
  2. Compare with https://catalog.data.gov/search?q=%22baby%20names%22
  3. Try a phrase that matches nothing: https://catalog.data.gov/search?q=%22zzzqqq%20nomatch%22%20california

Expected behavior

  • Results must contain the phrase "baby names" and the word "california".
  • A phrase that matches nothing returns no results.

Actual behavior

  • The first and third searches both return the whole catalog, starting with "Electric Vehicle Population Data".
  • parse_search_query returns two terms with has_or false. build_base_query only handles one term in that case and otherwise falls back to {"match_all": {}}. The comment there says "Shouldn't happen, but fall back to match_all".

Sketch

  • When there's more than one term and no OR, combine them with a bool must, so every phrase and word has to match
  • Add unit tests for a phrase plus a word, and for two phrases without OR
Lingua principale
Python
Stelle
1.2k
Fork
207
Merge medio
3g 16h
PR unite (30g)
5

Preparare l'ambiente

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.

Altre issue di GSA/data.gov

Tutte le issue di GSA/data.gov

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.