From 693d8f421e358cdb20049f6c7bfc0dd394e9677b Mon Sep 17 00:00:00 2001 From: Brian Austin Date: Sat, 6 Apr 2024 21:26:46 -0400 Subject: [PATCH] Fix typo and use existing method for index --- app/controllers/autocomplete_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index 80a72630195..4f8d6936604 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -102,7 +102,7 @@ def noncanonical_tag # As explained in https://stackoverflow.com/a/54080114, the Elasticsearch suggestion suggester does not support # matches in the middle of a series of words. Therefore, we break the autocomplete query into its individual - # words – based on whitespace – except for the last word, which could be a incomplete, so a prefix match is + # words – based on whitespace – except for the last word, which could be incomplete, so a prefix match is # appropriate. This emulates the behavior of SQL `LIKE '%text%'. word_list = search_param.split @@ -111,7 +111,7 @@ def noncanonical_tag begin # Size is chosen so we get enough search results from each shard. search_results = $elasticsearch.search( - index: "#{ArchiveConfig.ELASTICSEARCH_PREFIX}_#{Rails.env}_tags", + index: TagIndexer.index_name, body: { size: "100", query: { bool: { filter: [{ match: { tag_type: params[:type].capitalize } }, { match: { canonical: false } }], must: search_list } } } ) render_output(match + search_results["hits"]["hits"].first(10).map { |t| t["_source"]["name"] })