Project

General

Profile

Query » History » Version 28

Chengyu Fan, 09/05/2015 08:19 AM

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
            }
90
        },
91
        "required": []
92
    }
93
}
94
95 13 Alison Craig
```
96
97
98 23 Anonymous
## Query Results
99 1 Alison Craig
100 23 Anonymous
Catalogs answer queries with one or more Query Result Data packets. Each packet contains a JSON list of matching NDN name URIs
101
Query responses are Data containing a JSON list of matching name URIs. Each packet is named according to:
102 1 Alison Craig
103 28 Chengyu Fan
    /<prefix>/query-results/<catalog-id>/<query-parameters>/<version>/<segmentNumber>
104 15 Alison Craig
105 26 Chengyu Fan
The response set is versioned and uniquely identifies the catalog that produced it (e.g. identity key digest).
106 23 Anonymous
107
### Query Results Data JSON
108
109
110 20 Alison Craig
```
111
{
112
    "$schema": "http://json-schema.org/draft-04/schema#",
113
    "title": "Catalog Query Result",
114
    "type": "array",
115 1 Alison Craig
    "items": {
116
        "title": "QueryResults",
117
        "type": "object",
118
        "properties": {
119 26 Chengyu Fan
            "resultCount": {
120
               "description": "The total number of the records in query results"
121 27 Chengyu Fan
               "type": unsigned integer
122 26 Chengyu Fan
            },
123 23 Anonymous
            "results": {
124
               "description": "List of NDN name URIs"
125 20 Alison Craig
               "type": Array
126 1 Alison Craig
            },
127 26 Chengyu Fan
            "next": {
128 20 Alison Craig
                "description": "Autocomplete search potential next field(s)"
129
                "type": Array
130
            }
131 15 Alison Craig
        },
132 26 Chengyu Fan
        "required": [resultCount]
133 15 Alison Craig
    },
134
    
135
}
136
```