Skip to content

Commit

Permalink
#677 multi parent query wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Oct 10, 2023
1 parent 318fb2d commit 5528766
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server/src/handlers/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub struct SearchQuery {
pub include: Option<bool>,
/// Maximum amount of results
pub limit: Option<usize>,
/// Only include resources that have this resource as its ancestor
pub parent: Option<String>,
/// Only include resources that have one of these resources as its ancestor
pub parents: Option<Vec<String>>,
/// Filter based on props, using tantivy QueryParser syntax.
/// e.g. `prop:val` or `prop:val~1` or `prop:val~1 AND prop2:val2`
/// See https://docs.rs/tantivy/latest/tantivy/query/struct.QueryParser.html
Expand Down Expand Up @@ -147,9 +147,14 @@ fn query_from_params(
) -> AtomicServerResult<impl Query> {
let mut query_list: Queries = Vec::new();

if let Some(parent) = &params.parent {
let query = build_parent_query(parent, fields, &appstate.store)?;
if let Some(parents) = &params.parents {
let mut queries: Vec<Box<dyn Query>> = Vec::new();
for parent in parents {
let boxed_q = build_parent_query(parent, fields, &appstate.store)?;
queries.push(Box::new(boxed_q));
}

let query = BooleanQuery::union(queries);
query_list.push((Occur::Must, Box::new(query)));
}

Expand Down

0 comments on commit 5528766

Please sign in to comment.