4

Is there any way to use the contains() filter in a SODA2 API call. Something like this, but I get a response saying the query is too complex -

http://data.cityofchicago.org/resource/4ijn-s7e5.json?$select=dba_name&$where=contains(dba_name,'Some string')

{
  "code" : "query.execution.queryTooComplex",
  "error" : true,
  "message" : "Only simple comparison filters are allowed",
  "data" : {
    "reason" : "validation.complex-filter"
  }
}

When you view the dataset here you're able to create different filter view conditions like 'DBA Name contains apple', so I was just wondering if there was a way to do the same thing using the SODA2 API endpoint.

This is for an iOS App also. My current solution is just storing a years worth of data on the device and then doing all the operations I need on my own.

Thanks!

3
  • Not sure about your questions, but perhaps this will help. If you're familiar with R, there is a library for connecting with Socrata from R, called RSocrata cran.r-project.org/web/packages/RSocrata/index.html
    – sckott
    Commented Apr 22, 2014 at 1:22
  • I realized my answer below isn't specific to "socrata". Please update your question if you are looking for answers using a specific software or tool.
    – philshem
    Commented Apr 22, 2014 at 10:14
  • I just updated my question, hopefully it is more specific now.
    – James
    Commented Apr 22, 2014 at 13:26

1 Answer 1

1

Update: I realized my answer is for the browser and not related to Socrata. I'll probably delete it soon.


Your core URI is

http://data.cityofchicago.org/resource/4ijn-s7e5.json

which is actually just a large JSON file.

It's possible to use the browser to filter the JSON file. After the core URI above, you put a question mark (?) and then the filters. For example, to get inspection_id # 1434955, the URL will be constructed as follows:

http://data.cityofchicago.org/resource/4ijn-s7e5.json?inspection_id=1434955

The key from the JSON file is inspection_id and the value is 1434955. These strings must match exactly, so it's most useful to use the complete JSON as a reference.

You can combine filters with ampersand (&). For example, this URI gives a JSON that combines all Zip Codes being 60649 and with Inspection Type being "Complaint"

http://data.cityofchicago.org/resource/4ijn-s7e5.json?zip=60649&inspection_type=Complaint

The keys are things like zip and inspection_type, and the values are things like 60649 and Complaint. There is also the ability to give the browser JSON with more complicated filters (greater than, less than), but those will require some documentation from the data source. Normally you put a JSON-like piece of text in your URI (for example). If you use a browser tool like discussed here, I think then you can easily search text in the JSON file.

If you don't know programming, consider learning cURL (don't mind the tacky website, it's really a core resource). Also, there are browser extensions that may make the process simpler (for example).

1
  • 1
    Actually, what you're describing is the CGI interface ... effectively the URL is of the form protocol://host/path?query, and the query is composed of key=value pairs, joined by ampersands (&). Note that some CGI interfaces will also accept semi-colons in place of ampersands, which is useful as they don't have to be escaped in the HTML.
    – Joe
    Commented Apr 22, 2014 at 14:09

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.