]>
cat aescling's git repositories - mastodon.git/blob - app/services/tag_search_service.rb
1 # frozen_string_literal: true
3 class TagSearchService
< BaseService
4 def call(query
, options
= {})
5 @query = query
.strip
.gsub(/\A#/, '')
6 @offset = options
[:offset].to_i
7 @limit = options
[:limit].to_i
9 results
= from_elasticsearch
if Chewy
.enabled
?
10 results
||= from_database
17 def from_elasticsearch
23 fields
: %w(name
.edge_ngram name
),
49 boost_mode
: 'multiply',
75 TagsIndex
.query(query
).filter(filter
).limit(@limit).offset(@offset).objects
.compact
76 rescue Faraday
::ConnectionFailed, Parslet
::ParseFailed
81 Tag
.search_for(@query, @limit, @offset)
This page took 0.083445 seconds and 4 git commands to generate.