|
|
|
@ -5,12 +5,21 @@ class TagsIndex < Chewy::Index
|
|
|
|
|
analyzer: {
|
|
|
|
|
content: {
|
|
|
|
|
tokenizer: 'keyword',
|
|
|
|
|
filter: %w(lowercase asciifolding cjk_width),
|
|
|
|
|
filter: %w(
|
|
|
|
|
word_delimiter_graph
|
|
|
|
|
lowercase
|
|
|
|
|
asciifolding
|
|
|
|
|
cjk_width
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
edge_ngram: {
|
|
|
|
|
tokenizer: 'edge_ngram',
|
|
|
|
|
filter: %w(lowercase asciifolding cjk_width),
|
|
|
|
|
filter: %w(
|
|
|
|
|
lowercase
|
|
|
|
|
asciifolding
|
|
|
|
|
cjk_width
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -30,12 +39,9 @@ class TagsIndex < Chewy::Index
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
root date_detection: false do
|
|
|
|
|
field :name, type: 'text', analyzer: 'content' do
|
|
|
|
|
field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
field :reviewed, type: 'boolean', value: ->(tag) { tag.reviewed? }
|
|
|
|
|
field :usage, type: 'long', value: ->(tag, crutches) { tag.history.aggregate(crutches.time_period).accounts }
|
|
|
|
|
field :last_status_at, type: 'date', value: ->(tag) { tag.last_status_at || tag.created_at }
|
|
|
|
|
field(:name, type: 'text', analyzer: 'content', value: :display_name) { field(:edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content') }
|
|
|
|
|
field(:reviewed, type: 'boolean', value: ->(tag) { tag.reviewed? })
|
|
|
|
|
field(:usage, type: 'long', value: ->(tag, crutches) { tag.history.aggregate(crutches.time_period).accounts })
|
|
|
|
|
field(:last_status_at, type: 'date', value: ->(tag) { tag.last_status_at || tag.created_at })
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|