thoth-pub / thoth

Metadata management and dissemination system for Open Access books
https://thoth.pub
Apache License 2.0
45 stars 9 forks source link

Rework API filtering logic #486

Open rhigman opened 1 year ago

rhigman commented 1 year ago
          Overall, rather than `TimeExpression` I'm more inclined to support filtering by field more widely. Something like:
pub enum Operator {
    Eq,
    Neq,
    Gt,
    Lt,
    Gte,
    Lte,
    Ilike,
}

pub struct WorkFilter {
    pub field: WorkField,
    pub operator: Operator,
    pub value: String,
}

fn works (
        [...]
        filters: Vec<WorkFilter>,
        [...]
)

Originally posted by @ja573 in https://github.com/thoth-pub/thoth/pull/484#pullrequestreview-1330564442

To do:

rhigman commented 1 year ago

OR statements

The existing filter logic creates two kinds of OR statements:

  1. Same field, multiple values [same operator]: e.g. filter_param_1 might be used to check for works whose workType equals monograph OR edited_book (this case was covered in the original design above)
  2. Same value, multiple fields [same operator]: e.g. filter might be used to check for works whose title OR abstract contains keyword
rhigman commented 1 year ago

In progress at https://github.com/thoth-pub/thoth/tree/feature/486_rework_filtering. Basic proof of concept achieved for statement type 2 above. Design work still needed on how to also handle type 1. Currently on hold.