Socrata SODA query search for multiple terms with OR operator

19 Views Asked by At

I would like to achieve an 'OR' operator search within a Socrata query. The Socrata docs have an example with a single term

https://soda.demo.socrata.com/resource/4tka-6guv.json?$q=Islands

The docs further explain that the AND is assumed if there are multiple terms.

Multiple search terms are ANDed together, rather than used as a phrase search

My question is how can I, if at all, achieve an OR operator.

My exploration so far

r = requests.get('https://soda.demo.socrata.com/resource/4tka-6guv.json?$q=BRITISH').json()
print('british',len(r))

r = requests.get('https://soda.demo.socrata.com/resource/4tka-6guv.json?$q=ISLANDS').json()
print('islands',len(r))

r = requests.get('https://soda.demo.socrata.com/resource/4tka-6guv.json?$q=ISLANDS OR BRITISH').json()
print('or',len(r))

r = requests.get('https://soda.demo.socrata.com/resource/4tka-6guv.json?$q=ISLANDS AND BRITISH').json()
print('and',len(r))

r = requests.get('https://soda.demo.socrata.com/resource/4tka-6guv.json?$q=ISLANDS BRITISH').json()
print('no operator',len(r))

The output: british 72 islands 385 or 66 and 66 no operator 66

So what I've learned is the AND operator is implied by multiple terms. Is it possible to search multiple terms inclusive as in an OR operator? I could do a 'WHERE' SQL type search, but I would prefer to search across fields without specifying the field names, as I may not know them in advance if I batch records.

0

There are 0 best solutions below