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

How to query by Topic? #273

Open
krisgulati opened this issue Sep 8, 2024 · 3 comments
Open

How to query by Topic? #273

krisgulati opened this issue Sep 8, 2024 · 3 comments
Labels
OpenAlex question Further information is requested

Comments

@krisgulati
Copy link

I understand that "concepts" are being deprecated and "topics" are coming in. But, I'm struggling to query to get topics.

What I'm trying to do is construct an oa_fetch to get the authors with certain topics.

However, when I try something like the following query I get the response, "no records found"

try = oa_fetch(
topics.id = "T13075",
entity = "authors",
verbose = TRUE,
options = list(sample = 20, seed = 1)
)

The same is true when I replace "topics.id" with "topic_share.id"

However, when I change the query above from "entity="authors"" to "entity = "works"" the query does indeed work -- but I don't want the works I want the authors.

@yjunechoe
Copy link
Collaborator

yjunechoe commented Sep 8, 2024

I can replicate this and my impression is that OpenAlex is still rolling out Topics as a filter.

So for Works objects, I see that you can now filter by Topics (vs. Concepts):

https://docs.openalex.org/api-entities/works/filter-works

  • topics.id
  • topics.domain.id
  • topics.field.id
  • topics.subfield.id

But for Authors, there's only a filter by Concepts and it's still marked as to-be deprecated:

https://docs.openalex.org/api-entities/authors/filter-authors

  • x_concepts.id (alias: concepts.id or concept.id) -- will be deprecated soon

I suspect this will resolve itself with time

@krisgulati
Copy link
Author

Thank you for responding so quickly and on the weekend! Sorry, I was going crazy trying to find a solution.

@yjunechoe
Copy link
Collaborator

No worries! This was good to check. For what it's worth I see the x_concepts.id filter still working fine - maybe that can get you started on something without waiting on the Topics filter to become available:

library(dplyr)

concepts_CS <- oa_fetch(
  entity = "concepts",
  search = "Computer Science"
) %>% 
  filter(level == 0) %>% 
  pull(id)
concepts_CS
#> [1] "https://openalex.org/C41008148"

oa_fetch(
  x_concepts.id = concepts_CS,
  entity = "authors",
  verbose = TRUE,
  options = list(sample = 1, seed = 1)
)
#> Requesting url: https://api.openalex.org/authors?filter=x_concepts.id%3Ahttps%3A%2F%2Fopenalex.org%2FC41008148&sample=1&seed=1
#> Getting 1 page of results with a total of 1 records...
#> # A tibble: 1 × 18
#>   id                  display_name display_name_alterna…¹ relevance_score ids   orcid works_count
#>   <chr>               <chr>        <list>                           <dbl> <lis> <lgl>       <int>
#> 1 https://openalex.o… K.S. McFall  <chr [3]>                         1.00 <chr> NA             10
#> # ℹ abbreviated name: ¹​display_name_alternatives
#> # ℹ 11 more variables: cited_by_count <int>, counts_by_year <list>,
#> #   affiliation_display_name <chr>, affiliation_id <chr>, affiliation_ror <chr>,
#> #   affiliation_country_code <chr>, affiliation_type <chr>, affiliation_lineage <chr>,
#> #   affiliations_other <list>, topics <list>, works_api_url <chr>

@yjunechoe yjunechoe added question Further information is requested OpenAlex labels Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OpenAlex question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants