mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-07 12:16:14 +00:00
Change account search to be more forgiving of spaces (#34455)
This commit is contained in:
parent
7a70d95435
commit
91db45b197
|
@ -19,9 +19,16 @@ class AccountsIndex < Chewy::Index
|
||||||
type: 'stemmer',
|
type: 'stemmer',
|
||||||
language: 'possessive_english',
|
language: 'possessive_english',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
word_joiner: {
|
||||||
|
type: 'shingle',
|
||||||
|
output_unigrams: true,
|
||||||
|
token_separator: '',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
analyzer: {
|
analyzer: {
|
||||||
|
# "The FOOING's bar" becomes "foo bar"
|
||||||
natural: {
|
natural: {
|
||||||
tokenizer: 'standard',
|
tokenizer: 'standard',
|
||||||
filter: %w(
|
filter: %w(
|
||||||
|
@ -35,11 +42,20 @@ class AccountsIndex < Chewy::Index
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# "FOO bar" becomes "foo bar"
|
||||||
verbatim: {
|
verbatim: {
|
||||||
tokenizer: 'standard',
|
tokenizer: 'standard',
|
||||||
filter: %w(lowercase asciifolding cjk_width),
|
filter: %w(lowercase asciifolding cjk_width),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# "Foo bar" becomes "foo bar foobar"
|
||||||
|
word_join_analyzer: {
|
||||||
|
type: 'custom',
|
||||||
|
tokenizer: 'standard',
|
||||||
|
filter: %w(lowercase asciifolding cjk_width word_joiner),
|
||||||
|
},
|
||||||
|
|
||||||
|
# "Foo bar" becomes "f fo foo b ba bar"
|
||||||
edge_ngram: {
|
edge_ngram: {
|
||||||
tokenizer: 'edge_ngram',
|
tokenizer: 'edge_ngram',
|
||||||
filter: %w(lowercase asciifolding cjk_width),
|
filter: %w(lowercase asciifolding cjk_width),
|
||||||
|
|
|
@ -128,11 +128,37 @@ class AccountSearchService < BaseService
|
||||||
|
|
||||||
def core_query
|
def core_query
|
||||||
{
|
{
|
||||||
multi_match: {
|
dis_max: {
|
||||||
query: @query,
|
queries: [
|
||||||
type: 'best_fields',
|
{
|
||||||
fields: %w(username^2 display_name^2 text text.*),
|
match: {
|
||||||
operator: 'and',
|
username: {
|
||||||
|
query: @query,
|
||||||
|
analyzer: 'word_join_analyzer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
match: {
|
||||||
|
display_name: {
|
||||||
|
query: @query,
|
||||||
|
analyzer: 'word_join_analyzer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
multi_match: {
|
||||||
|
query: @query,
|
||||||
|
type: 'best_fields',
|
||||||
|
fields: %w(text text.*),
|
||||||
|
operator: 'and',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
tie_breaker: 0.5,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user