"""Diagnostic for the keyword-mode misses (not part of the main table, which keeps defaults). Runs the six questions in keyword mode with the default matchingStrategy (last) and with "all" and "frequency". Prints hits returned (limit 50), estimatedTotalHits and the rank of the expected page among the first 5 pages.""" from common import FETCH, hit_rank, meili, questions print("keyword mode, limit", FETCH, "| rank = expected page among first 5 pages (- = miss)") for strategy in ("last", "all", "frequency"): print(f"\nmatchingStrategy {strategy}" + (" (default)" if strategy == "last" else "")) hits_ok = 0 for q in questions(): res = meili("POST", "/indexes/docs/search", {"q": q["question"], "limit": FETCH, "matchingStrategy": strategy, "attributesToRetrieve": ["url"]}) r = hit_rank([h["url"] for h in res["hits"]], q["expected_url_contains"]) hits_ok += r is not None print(f" {q['question'][:62]:<64} hits {len(res['hits']):>2} estimatedTotalHits {res['estimatedTotalHits']:>3} rank {r or '-'}") print(f" expected page in top 5: {hits_ok}/6") print("\nthe shared opening words alone (default strategy):") for text in ("How do I", "How do I cancel"): res = meili("POST", "/indexes/docs/search", {"q": text, "limit": FETCH, "attributesToRetrieve": ["url"]}) print(f" '{text}': hits {len(res['hits'])} estimatedTotalHits {res['estimatedTotalHits']}")