digital-science / dimcli

Python client and CLI for scientometrics and research analytics using the Dimensions API.
https://digital-science.github.io/dimcli/getting-started.html
MIT License
43 stars 6 forks source link

Dimensions API - Complex search queries return 'DSL to dataframe magic methods work only with `search` queries.' issues when applying dsl.query() #70

Closed NeilCollinsMS closed 3 weeks ago

NeilCollinsMS commented 2 years ago

Documentation link: https://api-lab.dimensions.ai/cookbooks/1-getting-started/3-Working-with-dataframes.html#The-Dimcli-Python-library:-Working-with-Pandas-Dataframes

Using complex search queries yields the 'DSL to dataframe magic methods work only with search queries' error despite being applied to a stored search query. An example can be found below:

%%dsldf

query = """search publications where ( (research_orgs.id = "grid.######.1" and research_orgs.id = "grid.######.6") ) and ( year = 2020 or year = 2021 ) return [id+authors+year+research_orgs]""" res = dsl.query(query)

Adjustments have been made to query fields, but do not yield any fixes. Is it possible that this method only works on term searching?

lambdamusic commented 2 years ago

I think you are getting the syntax wrong. After the cell magic, you can't enter Python code, just Dimensions Search Language statements. EG this works


%%dsldf

search publications
    where
    (
    (research_orgs.id = "grid.10837.3d" and research_orgs.id = "grid.4991.5")
    )
and (
    year = 2020
    or year = 2021
    )
return publications[id+authors+year+research_orgs]

See the results in my notebook:

image