Query » History » Revision 23
Revision 22 (Alison Craig, 03/04/2015 01:54 PM) → Revision 23/29 (Anonymous, 03/04/2015 02:23 PM)
# Catalog Query API Catalogs feature an NDN name-based query API to enable discovery. ## ===== The Query Request Catalog queries parameter are expressed named as a JSON <query-parameters> an Interest name component: /<prefix>/query/<query-parameters> with a Data response of /<prefix>/query/<query-parameters>/<view> For the Query parameters simultaneously support two types of queries: 1. component type-based 2. absolute prefix-based The requestor Protocol, the user will encode send query parameters as a JSON object, list, with the format: <tt>{[field1]=[search1],[field2]=[search2],?=[search3]</tt>} where <tt>field1</tt> and <tt>field2</tt> are Name components. components, <tt>?</tt> indicates an absolute prefix-based autocomplete search where <tt>search3</tt> search, and <tt>search*</tt> is the prefix. what to use for searching on. <i>(See [[Schema]])</i> ### In response, the Query Parameters Schema backend of the Catalog will make Data available that includes a list of names that match the query. ---- <b>JSON Schemas</b> <b><i>JSON Query</i></b> The query name is formatted JSON stored in the query-parameters of the Interest: /<prefix>/query/<query-parameters> ``` { "$schema": "http://json-schema.org/draft-04/schema#", "title": "catalog query", "type": "object", "items": { "title": "query parameters", "type": "object", "properties": { "name": { "type": "string" }, "activity": { "type": "string" }, "product": { "type": "string" }, "organization": { "type": "string" }, "model": { "type": "string" }, "experiment": { "type": "string" }, "frequency": { "type": "string" }, "modeling realm": { "type": "string" }, "variable name": { "type": "string" }, "ensemble member": { "type": "string" }, "ensemble": { "type": "string" }, "sample granularity": { "type": "string" }, "start time": { "type": "string" }, "field campaign": { "type": "string" }, "optical properties for radiation": { "type": "string" }, "grid resolution": { "type": "string" }, "output type": { "type": "string" }, "timestamp": { "type": "string" }, "?": { "description": "Autocomplete search field" "type": "string" } }, "required": [] } } ``` ## Query <b><i>Query Results Catalogs answer queries with one or more Query Result Data packets. Each packet contains a JSON list of matching NDN name URIs JSON</b></i> Query responses are Data containing a JSON list of matching name URIs. Each packet is named according to: /<prefix>/query/<query-parameters>/<version>/<catalog-id>/<view-begin>/<view-end>/<result-count> Each Data packet represents a "view" of With the complete result set. The Data's name specifies query results, the begin and end range of Data returns the current view as well as Query Results by using the total number of matching results. The response set is versioned and uniquely identifies query parameters (above) in the catalog that Name produced it (e.g. identity key digest). Upon receiving an acceptably recent version response, requesters may iterate through subsequent views and a JSON Blob for the (specified catalog, version) pair. results: /<prefix>/query/<query-parameters>/<view> ### Query Results Data JSON In addition, there is a view pair in the Name to indicate the results desired ``` { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Catalog Query Result", "type": "array", "items": { "title": "QueryResults", "type": "object", "properties": { "results": "Results": { "description": "List of NDN name URIs" names" "type": Array }, "? next": "Next": { "description": "Autocomplete search potential next field(s)" "type": Array } }, "required": [] }, } ``` <b><i>Query View Data JSON</b></i> ``` { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Catalog Query Result", "type": "array", "items": { "title": "QueryView", "type": "object", "properties": { "Length": { "description": "Total number of results" "type": "integer" }, "View": { "minimum": 2 "maximum": 2 "description": "Pair of integers indicating which subset of the results we are receiving (first value being the lower index, second the upper index)" "type": Array }, }, "required": [Length,View] }, } ```