Fix account search results (#30803)
This commit is contained in:
parent
07d222665b
commit
a40831b363
1 changed files with 20 additions and 32 deletions
|
@ -28,9 +28,7 @@ class AccountSearchService < BaseService
|
||||||
},
|
},
|
||||||
|
|
||||||
functions: [
|
functions: [
|
||||||
reputation_score_function,
|
|
||||||
followers_score_function,
|
followers_score_function,
|
||||||
time_distance_function,
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -81,36 +79,12 @@ class AccountSearchService < BaseService
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# This function deranks accounts that follow more people than follow them
|
|
||||||
def reputation_score_function
|
|
||||||
{
|
|
||||||
script_score: {
|
|
||||||
script: {
|
|
||||||
source: "(Math.max(doc['followers_count'].value, 0) + 0.0) / (Math.max(doc['followers_count'].value, 0) + Math.max(doc['following_count'].value, 0) + 1)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# This function promotes accounts that have more followers
|
# This function promotes accounts that have more followers
|
||||||
def followers_score_function
|
def followers_score_function
|
||||||
{
|
{
|
||||||
script_score: {
|
script_score: {
|
||||||
script: {
|
script: {
|
||||||
source: "(Math.max(doc['followers_count'].value, 0) / (Math.max(doc['followers_count'].value, 0) + 1))",
|
source: "Math.log10((Math.max(doc['followers_count'].value, 0) + 1))",
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# This function deranks accounts that haven't posted in a long time
|
|
||||||
def time_distance_function
|
|
||||||
{
|
|
||||||
gauss: {
|
|
||||||
last_status_at: {
|
|
||||||
scale: '30d',
|
|
||||||
offset: '30d',
|
|
||||||
decay: 0.3,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -125,11 +99,25 @@ class AccountSearchService < BaseService
|
||||||
private
|
private
|
||||||
|
|
||||||
def core_query
|
def core_query
|
||||||
|
{
|
||||||
|
dis_max: {
|
||||||
|
queries: [
|
||||||
{
|
{
|
||||||
multi_match: {
|
multi_match: {
|
||||||
query: @query,
|
query: @query,
|
||||||
type: 'bool_prefix',
|
type: 'most_fields',
|
||||||
fields: %w(username^2 username.*^2 display_name display_name.*),
|
fields: %w(username username.*),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
multi_match: {
|
||||||
|
query: @query,
|
||||||
|
type: 'most_fields',
|
||||||
|
fields: %w(display_name display_name.*),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -142,7 +130,7 @@ class AccountSearchService < BaseService
|
||||||
{
|
{
|
||||||
multi_match: {
|
multi_match: {
|
||||||
query: @query,
|
query: @query,
|
||||||
type: 'most_fields',
|
type: 'best_fields',
|
||||||
fields: %w(username^2 display_name^2 text text.*),
|
fields: %w(username^2 display_name^2 text text.*),
|
||||||
operator: 'and',
|
operator: 'and',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue