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

Boolean operators query #60

Open
drumstick90 opened this issue Feb 7, 2025 · 1 comment
Open

Boolean operators query #60

drumstick90 opened this issue Feb 7, 2025 · 1 comment

Comments

@drumstick90
Copy link

drumstick90 commented Feb 7, 2025

Hi can't get my head around on how to query by pyalex for the following :

(alpha OR bravo OR charlie) AND (delta OR gamma)

This is not working corrrectly:

query_results = (
Works()
.search("(alpha OR bravo OR charlie) AND (delta OR gamma) ")
.paginate(per_page=100, n_max=max_results)
)

getting desperate

@PeterLombaers
Copy link
Collaborator

Hey @drumstick90 !
If I run the following:

import pyalex

print(
    pyalex.Works()
    .select(["id", "title"])
    .search("(alpha OR bravo OR charlie) AND (delta OR gamma) ")
    .get()
)

I get the response

[{'id': 'https://openalex.org/W2047982128', 'title': 'Differential expression of peroxisome proliferator-activated receptors (PPARs): tissue distribution of PPAR-alpha, -beta, and -gamma in the adult rat.'}, {'id': 'https://openalex.org/W2036007897', 'title': 'Gamma, alpha, delta, and theta oscillations govern cognitive processes'}, ...

That response seems correct for the boolean query you gave. Maybe, the problem is that you are not using the paginator correctly? Check out this example of pagination to see how you could do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants