cambialens / lens-api-doc

10 stars 6 forks source link

Applying filtering in the GET request #63

Closed csaparna closed 1 year ago

csaparna commented 1 year ago

Hi, I could not find an example of using filtering fields on the GET request. Could you please provide an example of using a field starting with "has_" with its boolean output in a GET request?

My example request url is:

url  = 'https://api.lens.org/scholarly/search?token='+token+'&size=100&query=NLRP3'\
                                                            '&has_clinical_trial=true'\
                                                            '&include=source.title,lens_id,clinical_trials'\
                                                            '&sort=desc(date_published)'
r =requests.get(url)
r.content

I get a response without any error for this request. However, it neither filters for having clinical trial, nor includes the clinical trial field in any of the records returned. I am sure that there are records with clinical trial for this query since they are visible through the lens website.

AaronBallagh commented 1 year ago

Hello,

Thank you for this question and for reporting this issue.

You can include the boolean field as part of the GET request query e.g. NLRP3 AND has_clinical_trial:true to filter your results. E.g. https://api.lens.org/scholarly/search?token={YOUR-TOKEN}&size=100&query=NLRP3%20AND%20has_clinical_trial:true&include=source.title,lens_id,clinical_trials&sort=desc(date_published)

image

I hope this helps, thanks again for reporting the issue.

Aaron

csaparna commented 1 year ago

Thank you very much @AaronBallagh ! That was really helpful and it worked.