Query » History » Version 29
Chengyu Fan, 10/07/2015 12:47 PM
| 1 | 23 | Anonymous | # Catalog Query API |
|---|---|---|---|
| 2 | 1 | Alison Craig | |
| 3 | 23 | Anonymous | Catalogs feature an NDN name-based query API to enable discovery. |
| 4 | 1 | Alison Craig | |
| 5 | 9 | Alison Craig | |
| 6 | 23 | Anonymous | ## Query Request |
| 7 | 1 | Alison Craig | |
| 8 | 23 | Anonymous | Catalog queries are expressed as a JSON <query-parameters> Interest name component: |
| 9 | 1 | Alison Craig | |
| 10 | 23 | Anonymous | /<prefix>/query/<query-parameters> |
| 11 | 1 | Alison Craig | |
| 12 | 23 | Anonymous | Query parameters simultaneously support two types of queries: |
| 13 | 1 | Alison Craig | |
| 14 | 23 | Anonymous | 1. component type-based |
| 15 | 2. absolute prefix-based |
||
| 16 | 14 | Alison Craig | |
| 17 | 23 | Anonymous | 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> |
| 18 | 15 | Alison Craig | |
| 19 | 23 | Anonymous | ### Query Parameters Schema |
| 20 | 15 | Alison Craig | |
| 21 | |||
| 22 | 13 | Alison Craig | ``` |
| 23 | 1 | Alison Craig | |
| 24 | 13 | Alison Craig | { |
| 25 | "$schema": "http://json-schema.org/draft-04/schema#", |
||
| 26 | 16 | Anonymous | "title": "catalog query", |
| 27 | "type": "object", |
||
| 28 | 13 | Alison Craig | "items": { |
| 29 | 16 | Anonymous | "title": "query parameters", |
| 30 | 13 | Alison Craig | "type": "object", |
| 31 | "properties": { |
||
| 32 | 16 | Anonymous | "name": { |
| 33 | 13 | Alison Craig | "type": "string" |
| 34 | }, |
||
| 35 | 16 | Anonymous | "activity": { |
| 36 | 13 | Alison Craig | "type": "string" |
| 37 | }, |
||
| 38 | 16 | Anonymous | "product": { |
| 39 | 13 | Alison Craig | "type": "string" |
| 40 | }, |
||
| 41 | 16 | Anonymous | "organization": { |
| 42 | 13 | Alison Craig | "type": "string" |
| 43 | }, |
||
| 44 | 16 | Anonymous | "model": { |
| 45 | 13 | Alison Craig | "type": "string" |
| 46 | }, |
||
| 47 | 16 | Anonymous | "experiment": { |
| 48 | 13 | Alison Craig | "type": "string" |
| 49 | }, |
||
| 50 | 16 | Anonymous | "frequency": { |
| 51 | 13 | Alison Craig | "type": "string" |
| 52 | }, |
||
| 53 | 1 | Alison Craig | "modeling realm": { |
| 54 | "type": "string" |
||
| 55 | }, |
||
| 56 | "variable name": { |
||
| 57 | "type": "string" |
||
| 58 | 13 | Alison Craig | }, |
| 59 | "ensemble member": { |
||
| 60 | "type": "string" |
||
| 61 | }, |
||
| 62 | 16 | Anonymous | "ensemble": { |
| 63 | 13 | Alison Craig | "type": "string" |
| 64 | 16 | Anonymous | }, |
| 65 | 17 | Anonymous | "sample granularity": { |
| 66 | 13 | Alison Craig | "type": "string" |
| 67 | 16 | Anonymous | }, |
| 68 | "start time": { |
||
| 69 | 13 | Alison Craig | "type": "string" |
| 70 | 16 | Anonymous | }, |
| 71 | "field campaign": { |
||
| 72 | 13 | Alison Craig | "type": "string" |
| 73 | }, |
||
| 74 | "optical properties for radiation": { |
||
| 75 | "type": "string" |
||
| 76 | }, |
||
| 77 | "grid resolution": { |
||
| 78 | "type": "string" |
||
| 79 | 16 | Anonymous | }, |
| 80 | "output type": { |
||
| 81 | 13 | Alison Craig | "type": "string" |
| 82 | }, |
||
| 83 | "timestamp": { |
||
| 84 | "type": "string" |
||
| 85 | 1 | Alison Craig | }, |
| 86 | 13 | Alison Craig | "?": { |
| 87 | 1 | Alison Craig | "description": "Autocomplete search field" |
| 88 | "type": "string" |
||
| 89 | 29 | Chengyu Fan | }, |
| 90 | "??": { |
||
| 91 | "description": "Prefix-based search" |
||
| 92 | "type": "string" |
||
| 93 | 1 | Alison Craig | } |
| 94 | }, |
||
| 95 | "required": [] |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | 13 | Alison Craig | ``` |
| 100 | |||
| 101 | |||
| 102 | 23 | Anonymous | ## Query Results |
| 103 | 1 | Alison Craig | |
| 104 | 23 | Anonymous | Catalogs answer queries with one or more Query Result Data packets. Each packet contains a JSON list of matching NDN name URIs |
| 105 | Query responses are Data containing a JSON list of matching name URIs. Each packet is named according to: |
||
| 106 | 1 | Alison Craig | |
| 107 | 28 | Chengyu Fan | /<prefix>/query-results/<catalog-id>/<query-parameters>/<version>/<segmentNumber> |
| 108 | 15 | Alison Craig | |
| 109 | 26 | Chengyu Fan | The response set is versioned and uniquely identifies the catalog that produced it (e.g. identity key digest). |
| 110 | 23 | Anonymous | |
| 111 | ### Query Results Data JSON |
||
| 112 | |||
| 113 | |||
| 114 | 20 | Alison Craig | ``` |
| 115 | { |
||
| 116 | "$schema": "http://json-schema.org/draft-04/schema#", |
||
| 117 | "title": "Catalog Query Result", |
||
| 118 | "type": "array", |
||
| 119 | 1 | Alison Craig | "items": { |
| 120 | "title": "QueryResults", |
||
| 121 | "type": "object", |
||
| 122 | "properties": { |
||
| 123 | 26 | Chengyu Fan | "resultCount": { |
| 124 | "description": "The total number of the records in query results" |
||
| 125 | 27 | Chengyu Fan | "type": unsigned integer |
| 126 | 26 | Chengyu Fan | }, |
| 127 | 23 | Anonymous | "results": { |
| 128 | "description": "List of NDN name URIs" |
||
| 129 | 20 | Alison Craig | "type": Array |
| 130 | 1 | Alison Craig | }, |
| 131 | 26 | Chengyu Fan | "next": { |
| 132 | 20 | Alison Craig | "description": "Autocomplete search potential next field(s)" |
| 133 | "type": Array |
||
| 134 | } |
||
| 135 | 15 | Alison Craig | }, |
| 136 | 26 | Chengyu Fan | "required": [resultCount] |
| 137 | 15 | Alison Craig | }, |
| 138 | |||
| 139 | } |
||
| 140 | ``` |