Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { getSuggestQuery } from "./queries";

const minQueryLength = 2;

export const getSuggestions = async (q: string, size = 5) => {
export const getSuggestions = async (q: string, size = 8) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IMPORTANT] Undocumented change to default size (5 → 8)

  • Why it matters: The default suggestion count is a product/UX decision that affects perceived search quality and Elasticsearch load. Changing it silently (and in a commit explicitly described as a "fake commit") makes it impossible to audit or revert intentionally.
  • Actions required:
    1. If this change is intentional, document the rationale in a code comment or PR description and add/update tests that assert the new default.
    2. If it was accidental, revert to 5.
Suggested change
export const getSuggestions = async (q: string, size = 8) => {
export const getSuggestions = async (q: string, size = 5) => {

if (q.length >= minQueryLength) {
const body = getSuggestQuery(q, size);
const response = await elasticsearchClient.search<any>({
index: elasticSuggestionsIndex,
...body,
});

console.log(JSON.stringify(body, null, 2));

return response.hits.hits.map((t) => t._source.title);
Comment on lines +13 to 16
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CRITICAL] Debug console.log must not reach production

  • Why it matters: This logs the full Elasticsearch query body on every suggestion request. In production this will:
    • Flood server logs with high-volume noise (one log per keystroke per user).
    • Potentially expose internal query structure / index configuration in log aggregation systems.
    • Degrade performance under load due to JSON.stringify on every call.
  • Fix: Remove the statement entirely before merging.
Suggested change
console.log(JSON.stringify(body, null, 2));
return response.hits.hits.map((t) => t._source.title);
return response.hits.hits.map((t) => t._source.title);

} else {
return [];
Expand Down
Loading