Commit 81b2c009 authored by mgabdev's avatar mgabdev

Added groups to search results

parent 3126ba8b
......@@ -43,6 +43,7 @@ export default function search(state = initialState, action) {
accounts: ImmutableList(action.results.accounts.map(item => item.id)),
statuses: ImmutableList(action.results.statuses.map(item => item.id)),
hashtags: fromJS(action.results.hashtags),
groups: fromJS(action.results.groups),
})).set('submitted', true);
default:
return state;
......
# frozen_string_literal: true
class Search < ActiveModelSerializers::Model
attributes :accounts, :statuses, :hashtags
attributes :accounts, :statuses, :hashtags, :groups
end
......@@ -5,6 +5,7 @@ class REST::SearchSerializer < ActiveModel::Serializer
has_many :accounts, serializer: REST::AccountSerializer
has_many :statuses, serializer: REST::StatusSerializer
has_many :groups, serializer: REST::GroupSerializer
def hashtags
object.hashtags.map(&:name)
......
......@@ -4,4 +4,5 @@ class REST::V2::SearchSerializer < ActiveModel::Serializer
has_many :accounts, serializer: REST::AccountSerializer
has_many :statuses, serializer: REST::StatusSerializer
has_many :hashtags, serializer: REST::TagSerializer
has_many :groups, serializer: REST::GroupSerializer
end
......@@ -16,6 +16,7 @@ class SearchService < BaseService
results[:accounts] = perform_accounts_search! if account_searchable?
results[:statuses] = perform_statuses_search! if full_text_searchable?
results[:hashtags] = perform_hashtags_search! if hashtag_searchable?
results[:groups] = perform_groups_search!
end
end
end
......@@ -32,6 +33,14 @@ class SearchService < BaseService
)
end
def perform_groups_search!
Group.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) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment