From f7d9935fb91274624ede99663fd47864ca79519f Mon Sep 17 00:00:00 2001 From: Bart van Bragt Date: Thu, 16 Apr 2026 11:57:34 +0200 Subject: [PATCH] feat: suppress ES instant results when search-post-bodies is enabled When searching inside comments is ON, the autocomplete dropdown now returns nothing from ES (only usernames show). This avoids showing title-only matches that are inconsistent with the full comment-body search results. Also passes filter[autocomplete]=1 to the API so the server uses the fast title.autocomplete path instead of the full has_child query. --- js/src/forum/SearchSources/DiscussionsSearchSource.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/src/forum/SearchSources/DiscussionsSearchSource.tsx b/js/src/forum/SearchSources/DiscussionsSearchSource.tsx index 1dc444a..99c0f9e 100644 --- a/js/src/forum/SearchSources/DiscussionsSearchSource.tsx +++ b/js/src/forum/SearchSources/DiscussionsSearchSource.tsx @@ -21,12 +21,18 @@ export default class DiscussionsSearchSource implements SearchSource { private type = 'discussions'; async search(query: string): Promise { + // Suppress ES instant results when "search within comments" is ON; + // only usernames are shown in that mode. + if (app.forum.attribute('blomstraSearchPostBodies')) { + return; + } + query = query.toLowerCase(); this.results.set(query, []); const params = { - filter: { q: query }, + filter: { q: query, autocomplete: 1 }, page: { limit: 3 }, include: 'mostRelevantPost', };