Skip to content

Commit

Permalink
Fix typo and use existing method for index
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjaustin committed Apr 7, 2024
1 parent e44d0ae commit 693d8f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/autocomplete_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"] })
Expand Down

0 comments on commit 693d8f4

Please sign in to comment.