Add native support for expressions via filters #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New
Add support for non-nested lists (e.g. list openalex_id's)
The following example didn't work before.
However, this results 0 in the latest API after this fix. This is because all lists are AND lists. There is no builtin OR list, which is needed for this example.
Add support for OR lists
This PR introduces the OR filter. This filter makes all arguments passed OR arguments if they contain multiple values.
Add support for NOT, >, <
It's even better; there are also
filter_not
,filter_gt
, andfilter_lt
. For example:Get 100 items in single call
Getting multiple items via OpenAlex keys now returns a maximum of 100 results (instead of 25).
Issue in OpenAlex REST API
For URL readability, PyAlex separates multi-valued keys with the AND token (
+
). OpenAlex supports this as described in https://docs.openalex.org/how-to-use-the-api/get-lists-of-entities/filter-entity-lists#intersection-and. The alternative is to use repeating filters as described in the docs.This works fine for basic filters but is inconsistent for more complex queries. For example, let's search for publications after 2021 but exclude 2023. This is straightforward:
https://api.openalex.org/works?filter=publication_year:>2021,publication_year:!2023
However, the alternative (preferred by PyAlex) doesn't work:
https://api.openalex.org/works?filter=publication_year:>2021+!2023
raises
{"error":"Invalid query parameters error.","message":"Value for param publication_year must be a number."}
Last time I looked, OpenAlex used Flask for the REST API. Flask offers support for repeated arguments, but Flask might not natively support the
+
.PyAlex will fail now on this:
TODO