Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query string helpers #30

Open
lukasschwab opened this issue May 19, 2019 · 1 comment
Open

Query string helpers #30

lukasschwab opened this issue May 19, 2019 · 1 comment
Assignees
Labels
enhancement Requests for new features or improvements.

Comments

@lukasschwab
Copy link
Owner

lukasschwab commented May 19, 2019

Atomic conditions

condition(field: "all"|"au"|..., value: string):

  • condition("au", "Balents Leon")"au:\"Balents Leon\""
  • condition("au", "balents_leon")"au:balents_leon"
  • condition("cat", "cond-mat.str-el")"au:cond-mat.str-el"
  • Open question: how to enumerate the available fields, values when they're enumerable.
prefix explanation
ti Title
au Author
abs Abstract
co Comment
jr Journal Reference
cat Subject Category
rn Report Number
id Id (use id_list instead)
all All of the above

Boolean assembly

These correspond to the three Boolean operators supported by the arXiv API.

and(cond1, cond2)"$(cond1) AND $(cond2)"

or(cond1, cond2)"$(cond1) OR $(cond2)"

andnot(cond1, cond2)"$(cond1) ANDNOT $(cond2)"

Grouping

group(cond)"($(cond))"

@lukasschwab lukasschwab added the enhancement Requests for new features or improvements. label May 19, 2019
@lukasschwab
Copy link
Owner Author

lukasschwab commented Aug 30, 2021

An example of some more advanced query construction: #83 (comment)

Open question: how to enumerate the available fields, values when they're enumerable.

Enums should be useful here, e.g. a (Query).Attribute enum: Attribute.Title, Attribute.Author, and so on.

The atomic conditions––arguments to and, or, andnot––are actually valid queries themselves. Which means they could be instead exposed as methods on the Query class:

  • cond1.and(cond2)
  • cond1.or(cond2)
  • cond1.andnot(cond2).andnot(cond3): I think this chaining is more literate than andnot(andnot(cond1, cond2), cond3).

It'd be nice to have arXiv as a source of truth for an enum of categories... but I might just have to accept the risk that the categories will change, and that new categories will have to be integrated here as patch releases. This is a good reason not to transform categories on Results into the enum type: new categories may not be explicitly queryable, but they should not break processing results.

Implementation detail: can build the string as we go along, or can assemble a tree which gets traversed to build the string.

We can use excessive grouping to convert queries to strings (so a.or(b) can yield (a) OR (b)). The group function expressed above may be unnecessary––group(a, b) may just be equivalent to a.or(b).

Good opportunity to define an interface and then write tests.

@lukasschwab lukasschwab self-assigned this Aug 30, 2021
@lukasschwab lukasschwab linked a pull request Aug 31, 2021 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests for new features or improvements.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant