Query » History » Revision 28
Revision 27 (Chengyu Fan, 07/16/2015 02:34 PM) → Revision 28/29 (Chengyu Fan, 09/05/2015 08:19 AM)
# Catalog Query API Catalogs feature an NDN name-based query API to enable discovery. ## Query Request Catalog queries are expressed as a JSON <query-parameters> Interest name component: /<prefix>/query/<query-parameters> Query parameters simultaneously support two types of queries: 1. component type-based 2. absolute prefix-based The requestor will encode query parameters as a JSON object, with the format: <tt>{[field1]=[search1],[field2]=[search2],?=[search3]</tt>} where <tt>field1</tt> and <tt>field2</tt> are Name components. <tt>?</tt> indicates an absolute prefix-based autocomplete search where <tt>search3</tt> is the prefix. <i>(See [[Schema]])</i> ### Query Parameters Schema ``` { "$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 Results Catalogs answer queries with one or more Query Result Data packets. Each packet contains a JSON list of matching NDN name URIs Query responses are Data containing a JSON list of matching name URIs. Each packet is named according to: /<prefix>/query-results/<catalog-id>/<query-parameters>/<version>/<segmentNumber> /<prefix>/query-results/<query-parameters>/<version>/<catalog-id>/<segmentNumber> The response set is versioned and uniquely identifies the catalog that produced it (e.g. identity key digest). ### Query Results Data JSON ``` { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Catalog Query Result", "type": "array", "items": { "title": "QueryResults", "type": "object", "properties": { "resultCount": { "description": "The total number of the records in query results" "type": unsigned integer }, "results": { "description": "List of NDN name URIs" "type": Array }, "next": { "description": "Autocomplete search potential next field(s)" "type": Array } }, "required": [resultCount] }, } ```