Added link/PreviewCard search to search

• Added:
- link/PreviewCard search to search
This commit is contained in:
mgabdev
2020-10-31 18:10:59 -05:00
parent 60f75ed676
commit 7e673d4e7f
9 changed files with 47 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ class SearchService < BaseService
results[:accounts] = perform_accounts_search! if account_searchable?
results[:statuses] = perform_statuses_search! if full_text_searchable? && !account.nil?
results[:hashtags] = perform_hashtags_search! if hashtag_searchable? && !account.nil?
results[:links] = perform_links_search! if !account.nil?
results[:groups] = perform_groups_search!
end
end
@@ -45,6 +46,14 @@ class SearchService < BaseService
)
end
def perform_links_search!
PreviewCard.search_for(
@query.gsub(/\A#/, ''),
@limit,
@offset
)
end
def perform_statuses_search!
definition = StatusesIndex.filter(term: { searchable_by: @account.id })
.query(multi_match: { type: 'most_fields', query: @query, operator: 'and', fields: %w(text text.stemmed) })
@@ -79,7 +88,7 @@ class SearchService < BaseService
end
def default_results
{ accounts: [], hashtags: [], statuses: [] }
{ accounts: [], hashtags: [], statuses: [], links: [], groups: [] }
end
def url_query?