Introduction
JSONsilo now supports searching data within silos. This feature allows you to search and interact with silo data programmatically. By adding specific search query parameters to your silo URL, you can search for precise information within your JSON data without needing to download or manually parse the entire dataset.This feature is currently supported only for Private Silos.
Limitations
While the search feature is powerful, it currently has some limitations:- Only private silos are supported; public silos are not yet available.
outputparameter is not supported in search functionality.
Usage
To search data from your private silo, you need to add specific query parameters to your silo URL. These parameters allow you to retrieve data dynamically based on your requirements.Notes:
- Make sure the parameters are in the correct order when combining them in a request.
- All parameters are required for the search to work.
- Default operator is
eq(equal to) if not specified.- Default response format is Array of Objects.
q: The path in the silo data to search.value: The value to search for at the specified path.op: The search operator to use (see the list of supported operators below).
Supported Operators
The following search operators are available:| Operator | Description |
|---|---|
eq | Equal to |
gt | Greater than |
lt | Less than |
ne | Not equal to |
lk | Like (case-sensitive) |
il | Insensitive like (case-insensitive) |
How It Works
The search functionality works by evaluating each object in a JSON array against the specified query parameters. Theq parameter defines the path to the field you want to search, the value parameter specifies the value to look for, and the op parameter indicates the comparison operator to use.
Example 1: Basic Search
Suppose you have a private silo containing an array of objects like this:data.json
age is greater than 25
- Use
?q=ageto specify the field to search. - Use
&value=25to set the value to compare against. - Use
&op=gtto set the operator to “greater than”.
Example 2: Nested Field
Suppose your silo data looks like this:data.json
profile.age is less than 30.
- Use
?q=profile.ageto specify the field to search. - Use
&value=30to set the value to compare against. - Use
&op=ltto set the operator to “less than”.
Example 3: Multiple Operators
🚧 Coming soon
Combining parameter with path
You can combine the search parameters with the path parameter to extract specific fields from the matched objects.
How It Works
When combining thepath parameter with search parameters, the search is performed first to filter the objects based on the criteria defined by q, value, and op. After filtering, the path parameter is applied to extract the specified field from each of the matched objects.
Suppose your silo data looks like this:
data.json
name of users whose profile.age is greater than 25, you would construct your request as follows:
- Use
?q=profile.ageto specify the field to search. - Use
&value=25to set the value to compare against. - Use
&op=gtto set the operator to “greater than”. - Use
&path=profile.nameto extract thenamefield from the matched objects.
Notes:
- The order of parameters is important. The search parameters (
q,value,op) should come before thepathparameter in the URL.- If no objects match the search criteria, the response will be an empty array.
- The
pathparameter can extract nested fields as well.- When using the
pathparameter, ensure that the specified path exists in the matched objects to avoidnullvalues in the response.