-
-
Save skanderm/907c9571caa0e87bad27 to your computer and use it in GitHub Desktop.
This file contains 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
# nested | |
if team_params[:role_id].present? || team_params[:weight_class_id].present? | |
nested path: 'role_requirements' do | |
query do | |
boolean do | |
must { term :weight_class_id, team_params[:weight_class_id]} if team_params[:weight_class_id].present? | |
must { term :role_id, team_params[:role_id] } if team_params[:role_id].present? | |
must { term :need, true } if team_params[:role_id].present? || team_params[:weight_class_id].present? | |
end | |
end | |
end | |
end | |
# Filtered | |
filtered do | |
boolean do | |
must { term :weight_class_id, team_params[:weight_class_id]} if team_params[:weight_class_id].present? | |
must { term :role_id, team_params[:role_id] } if team_params[:role_id].present? | |
must { term :need, true } if team_params[:role_id].present? || team_params[:weight_class_id].present? | |
end | |
end | |
# Filters: | |
if team_params[:weight_class_id].present? ^ team_params[:role_id].present? | |
filter :and, { term: {"role_requirements.weight_class_id" => team_params[:weight_class_id]}, term: {"role_requirements.need" => true} } if team_params[:weight_class_id].present? | |
filter :and, { term: {"role_requirements.role_id" => team_params[:role_id]}, term: {"role_requirements.need" => true} } if team_params[:role_id].present? | |
elsif team_params[:weight_class_id].present? && team_params[:role_id].present? | |
filter :and, { term: {"role_requirements.role_id" => team_params[:role_id]}, term: {"role_requirements.need" => true}, term: {"role_requirements.weight_class_id" => team_params[:weight_class_id]}} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment