Skip to content

Commit b66b771

Browse files
authored
Merge pull request #4679 from vespa-engine/johsol/json-query-language-fields
Johsol/json query language fields
2 parents 8f29a41 + bb09b53 commit b66b771

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

en/reference/api/query.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ <h3>Error code to status code mapping</h3>
23312331
<h2 id="select.json">select</h2>
23322332
<p>
23332333
A <code>select</code> query is equivalent in structure to YQL, written in JSON.
2334-
Contains subparameters <code>where</code> and <code>grouping</code>.
2334+
Contains subparameters <code>where</code>, <code>grouping</code> and <code>fields</code>.
23352335
</p>
23362336
<table class="table">
23372337
<thead>
@@ -2368,5 +2368,18 @@ <h2 id="select.json">select</h2>
23682368
</p>
23692369
</td>
23702370
</tr>
2371+
<tr>
2372+
<th>fields</th>
2373+
<td></td>
2374+
<td>String</td>
2375+
<td></td>
2376+
<td>
2377+
<p id="select.fields">
2378+
A JSON array of <a href="../../querying/document-summaries.html#selecting-summary-fields-in-yql">summary field</a>
2379+
names to include in each hit. Equivalent to the field list in a YQL <code>select</code> clause.
2380+
Refer to the <a href="../querying/json-query-language">select reference</a> for details.
2381+
</p>
2382+
</td>
2383+
</tr>
23712384
</tbody>
23722385
</table>

en/reference/querying/json-query-language.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The query has JSON syntax, and can be used with queries that are executed with H
1616
```json
1717
"select" : {
1818
"where" : {...},
19-
"grouping" : {...}
19+
"grouping" : {...},
20+
"fields" : [...]
2021
}
2122
```
2223

@@ -91,6 +92,34 @@ which is equivalent with the YQL.
9192

9293

9394

95+
### Fields
96+
97+
Available since {% include version.html version="8.680.18" %}.
98+
99+
The `fields` parameter restricts which
100+
[summary fields](../../querying/document-summaries.html#selecting-summary-fields-in-yql)
101+
are included in each hit. It is a JSON array of field names, and is equivalent
102+
to the field list in a YQL `select` clause.
103+
104+
YQL: `select id, title from sources * where title contains 'madonna'`.
105+
106+
Equivalent JSON:
107+
108+
```json
109+
{
110+
"select": {
111+
"fields": ["id", "title"],
112+
"where": {
113+
"contains": ["title", "madonna"]
114+
}
115+
}
116+
}
117+
```
118+
119+
If `fields` is omitted or empty, all fields of the chosen
120+
[document summary class](../../querying/document-summaries.html) are returned.
121+
122+
94123
### Grouping
95124

96125
One or more [grouping statements](../../querying/grouping.html) can be set as a JSON array in the `grouping` field.

0 commit comments

Comments
 (0)