Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
Make work_locations&salary location filters work in an OR-like capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Butler authored and Ryman committed Jul 17, 2018
1 parent ef30e3f commit e6c984a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/resources/talent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ impl Talent {
Query::build_range("salary_expectations.minimum")
.with_lte(max_salary)
.build(),
Query::build_term("salary_expectations.city", location)
.build()
])
.with_filter(Query::build_term("salary_expectations.city", location)
.build())
.build()
)
.build()
Expand Down Expand Up @@ -298,11 +298,15 @@ impl Talent {
i32_vec_from_params!(params, "presented_talents"),
date_filter_present,
),
Talent::salary_expectations_filters(params),
].into_iter()
.flat_map(|x| x)
.collect::<Vec<Query>>(),
)
.with_filter(
Query::build_bool()
.with_should(Talent::salary_expectations_filters(params))
.build()
)
.with_must_not(
vec![
<Query as VectorOfTerms<i32>>::build_terms(
Expand Down Expand Up @@ -1457,7 +1461,6 @@ mod tests {

let results = Talent::search(&mut client, &*index, &params);
// ignores talent 3 due to accepted == false
println!("{:#?}", results);
assert_eq!(vec![5, 2], results.ids());
}

Expand All @@ -1480,6 +1483,15 @@ mod tests {

let results = Talent::search(&mut client, &*index, &params);
assert_eq!(vec![5], results.ids());

// Ensure that work_locations are additive
let mut params = Map::new();
params.assign("maximum_salary", Value::String("30000".into())).unwrap();
params.assign("work_locations[]", Value::String("Amsterdam".into())).unwrap();
params.assign("work_locations[]", Value::String("Berlin".into())).unwrap();

let results = Talent::search(&mut client, &*index, &params);
assert_eq!(vec![5, 2], results.ids());
}
}

Expand Down

0 comments on commit e6c984a

Please sign in to comment.