|
|
|
@ -2,8 +2,37 @@ |
|
|
|
|
|
|
|
|
|
class AccountsIndex < Chewy::Index |
|
|
|
|
settings index: { refresh_interval: '30s' }, analysis: { |
|
|
|
|
filter: { |
|
|
|
|
english_stop: { |
|
|
|
|
type: 'stop', |
|
|
|
|
stopwords: '_english_', |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
english_stemmer: { |
|
|
|
|
type: 'stemmer', |
|
|
|
|
language: 'english', |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
english_possessive_stemmer: { |
|
|
|
|
type: 'stemmer', |
|
|
|
|
language: 'possessive_english', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
analyzer: { |
|
|
|
|
content: { |
|
|
|
|
natural: { |
|
|
|
|
tokenizer: 'uax_url_email', |
|
|
|
|
filter: %w( |
|
|
|
|
english_possessive_stemmer |
|
|
|
|
lowercase |
|
|
|
|
asciifolding |
|
|
|
|
cjk_width |
|
|
|
|
english_stop |
|
|
|
|
english_stemmer |
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
verbatim: { |
|
|
|
|
tokenizer: 'whitespace', |
|
|
|
|
filter: %w(lowercase asciifolding cjk_width), |
|
|
|
|
}, |
|
|
|
@ -26,18 +55,13 @@ class AccountsIndex < Chewy::Index |
|
|
|
|
index_scope ::Account.searchable.includes(:account_stat) |
|
|
|
|
|
|
|
|
|
root date_detection: false do |
|
|
|
|
field :id, type: 'long' |
|
|
|
|
|
|
|
|
|
field :display_name, type: 'text', analyzer: 'content' do |
|
|
|
|
field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
field :acct, type: 'text', analyzer: 'content', value: ->(account) { [account.username, account.domain].compact.join('@') } do |
|
|
|
|
field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
field :following_count, type: 'long', value: ->(account) { account.following_count } |
|
|
|
|
field :followers_count, type: 'long', value: ->(account) { account.followers_count } |
|
|
|
|
field :last_status_at, type: 'date', value: ->(account) { account.last_status_at || account.created_at } |
|
|
|
|
field(:id, type: 'long') |
|
|
|
|
field(:following_count, type: 'long') |
|
|
|
|
field(:followers_count, type: 'long') |
|
|
|
|
field(:properties, type: 'keyword', value: ->(account) { account.searchable_properties }) |
|
|
|
|
field(:last_status_at, type: 'date', value: ->(account) { account.last_status_at || account.created_at }) |
|
|
|
|
field(:display_name, type: 'text', analyzer: 'verbatim') { field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'verbatim' } |
|
|
|
|
field(:username, type: 'text', analyzer: 'verbatim', value: ->(account) { [account.username, account.domain].compact.join('@') }) { field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'verbatim' } |
|
|
|
|
field(:text, type: 'text', value: ->(account) { account.searchable_text }) { field :stemmed, type: 'text', analyzer: 'natural' } |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|