I'm trying extract some summary information from openFDA and am receiving wildly different responses, and very different capabilities when attempting my search, and was hoping that someone could help me out syntactically.

Attempting to count the number of events that report "hypertension" for substance name "venlafaxine hydrochloride" by dose level.

I noticed that when searching against the drug indication, I am able to supply a logical +AND+


Attempting to do the same thing is prevented when applying the same type of searchfor the meddra preferred term (event outcome) an API failure occurs with a 'hard' +AND+

search=(patient.drug.openfda.substance_name:"venlafaxine+hydrochloride"+AND+patient.reaction.reactionmeddrapt = "HYPERTENSION")&count=drugdosagetext

fails, but curiously: (note the lower case and)

search=(patient.drug.openfda.substance_name:"venlafaxine+hydrochloride" +and+ patient.reaction.reactionmeddrapt = "HYPERTENSION")&count=drugdosagetext

...doesn't fail (it does appear to result in a Cartesian error in the results however.

Is this because the indication is on the same table as the other drug information, whereas the preferred term is on a patient reaction table? Any way to get around this, nest the query, or link the tables?

  • 1
    This doesn't answer your question but unless something changed, the openFDA API sits on top of an ElasticSearch 'document-based' (as opposed to a relational) database system where there are no tables but instead each report is a document. Dec 3, 2014 at 19:13

1 Answer 1


Try adding .exact to the end of drugdosagetext

Also ... this does not count on the dosage but does get to a query of the former parameters - http://www.researchae.com/drugevent?from_date=2004-01-01&to_date=2015-01-31&from_age=&to_age=&search=venlafaxine+hydrochloride&country=GLOBALLY&patientsex=&manufacturername=&drugbrandname=&druggenericname=&medicinalproduct=&reactionmeddrapt=hypertension&drugclass=&drugindication=&indsubmit=&productndc=&safetyreportid=#stats

You can find the code here where you could simply append one of the "count" calls with the desired dosage field in the API. https://github.com/GeekNurse/ResearchAE-Open-Source/blob/master/app.rb#L1024


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.