-
-
Save regedarek/8f13ce2be820d9ef1959 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchService | |
def initialize(term) | |
@term = term | |
end | |
def profiles | |
term = @term | |
Tire.search('profiles', load: true, size: Profile.count) do | |
query do | |
custom_filters_score do | |
query { string term } | |
# If the Last Contact with this person is less than 7 monts ago, give a score of 1. | |
filter do | |
filter :range, last_contact_at: { gte: 7.days.ago } | |
boost 1 | |
end | |
# If currently available, give a score of 2 | |
filter do | |
filter :range, available_at: { gte: Date.today } | |
boost 2 | |
end | |
# If Profile is a Profile of a Akra Company Member, give this profile a score of 10. | |
filter do | |
filter :term, { company_type: 'intern' } | |
boost 10 | |
end | |
# If at least personally known by one person, give a score of 3, not more | |
filter do | |
filter :range, friends_count: { from: 1 } | |
boost 3 | |
end | |
# If blacklisted, show this profile on the end of the result list, not depending on the score. | |
filter do | |
filter :term, { blacklisted: true } | |
boost -100 | |
end | |
# Foreach Matching Focus, give a score of 5. | |
filter do | |
filter :term, { focuses: term } | |
boost 5 | |
end | |
# Foreach Matching "Tag" meaning found Word in the CV, with no focus, give a score of 4. | |
filter do | |
filter :term, { tags: term } | |
boost 4 | |
end | |
score_mode :total | |
end | |
end | |
raise to_json | |
end.results | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment