Skip to content

Commit

Permalink
Merge pull request #3521 from vespa-engine/hmusum/improve-partial-upd…
Browse files Browse the repository at this point in the history
…ate-doc

Minor improvement to partial update doc
  • Loading branch information
hmusum authored Dec 9, 2024
2 parents eced1d5 + 3efdc23 commit 166c54f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion en/document-v1-api-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<tr>
<th>PUT</th>
<td>
<p id="put"></p>
<p id="put">Do a <a href="partial-updates.html">partial update</a> for a document.</p>
<pre>
$ curl -X PUT -H "Content-Type:application/json" --data '
{
Expand Down
2 changes: 2 additions & 0 deletions en/partial-updates.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
A partial update is an update to one or more fields in a document.
It also includes updating all index structures
so the effect of the partial update is immediately observable in queries.
See <a href="reference/document-json-format.html#update">this example</a>
for how to do a partial update with the document v1 API.
</p>
<img src="/assets/img/attributes-update.svg" width="788px" height="auto"
alt="Attribute is an in-memory data structure" />
Expand Down
6 changes: 4 additions & 2 deletions en/reads-and-writes.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ <h2 id="operations">Operations</h2>
<th>Update</th>
<td><p>
Also referred to as <a href="partial-updates.html">partial updates</a>,
as it updates some/all fields of a document by ID.
as it updates one or more fields of a document by ID - the
<a href="document-v1-api-guide.html#put">document v1 API</a> can be used to perform
<a href="reference/document-json-format.html#update">updates in the JSON Document format</a>,
If the document to update is not found, it is not considered a failure.
</p><p>
Update supports <a href="document-v1-api-guide.html#create-if-nonexistent">create if nonexistent</a> (upsert).
Updates support <a href="document-v1-api-guide.html#create-if-nonexistent">create if nonexistent</a> (upsert).
</p><p>
Updates can have <a href="document-v1-api-guide.html#conditional-writes">conditions</a>
for test-and-set use cases.
Expand Down
64 changes: 32 additions & 32 deletions en/reference/document-json-format.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@



<h2 id="field-types">Field types</h2>
<h1 id="field-types">Field types</h1>
<table class="table">
<tr>
<th>string</th>
Expand Down Expand Up @@ -366,7 +366,7 @@ <h2 id="field-types">Field types</h2>
</table>


<h3 id="empty-fields">Empty fields</h3>
<h2 id="empty-fields">Empty fields</h3>
<p>
In general, fields that have not received a value during feeding will be ignored
when rendering the document. They are considered as empty fields.
Expand All @@ -377,7 +377,7 @@ <h3 id="empty-fields">Empty fields</h3>



<h2 id="document-operations">Document operations</h2>
<h1 id="document-operations">Document operations</h2>
<p>
Refer to <a href="../reads-and-writes.html">reads and writes</a> for details - alternatives:
</p>
Expand All @@ -394,7 +394,7 @@ <h2 id="document-operations">Document operations</h2>
</ul>


<h3 id="put">Put</h3>
<h2 id="put">Put</h3>
<p>
The "put" payload has a "put" operation and "fields"
(<a href="../document-v1-api-guide.html#post">/document/v1/ example</a>):
Expand All @@ -409,7 +409,7 @@ <h3 id="put">Put</h3>
{% endhighlight %}</pre>


<h3 id="get">Get</h3>
<h2 id="get">Get</h3>
<p>
"get" does not have a payload - the response has the same "field" object as in "put",
and also "id" and "pathId" fields
Expand All @@ -426,7 +426,7 @@ <h3 id="get">Get</h3>
{% endhighlight %}</pre>


<h3 id="remove">Remove</h3>
<h2 id="remove">Remove</h3>
<p>
The "remove" payload has a "remove" operation
(<a href="../document-v1-api-guide.html#delete">/document/v1/ example</a>):
Expand All @@ -438,7 +438,7 @@ <h3 id="remove">Remove</h3>
{% endhighlight %}</pre>


<h3 id="update">Update</h3>
<h2 id="update">Update</h3>
<p>
The "update" payload has an "update" operation and "fields"
(<a href="../document-v1-api-guide.html#put">/document/v1/ example</a>):
Expand All @@ -456,7 +456,7 @@ <h3 id="update">Update</h3>



<h2 id="test-and-set">Test and set</h2>
<h3 id="test-and-set">Test and set</h3>
<p>
An optional <em>condition</em> can be added to operations to specify a <em>test and set</em> condition -
see <a href="../document-v1-api-guide.html#conditional-writes">conditional writes</a>.
Expand All @@ -483,7 +483,7 @@ <h2 id="test-and-set">Test and set</h2>



<h2 id="create">create (create if nonexistent)</h2>
<h3 id="create">create (create if nonexistent)</h3>
<p>
<strong>Updates</strong> to nonexistent documents are supported using <em>create</em>.
(<a href="../document-v1-api-guide.html#create-if-nonexistent">/document/v1/ example</a>):
Expand Down Expand Up @@ -517,15 +517,15 @@ <h2 id="create">create (create if nonexistent)</h2>



<h2 id="assign">assign</h2>
<h3 id="assign">assign</h3>
<p>
<code>assign</code> is used to replace the value of a field (or an element of a collection) with a new value.
When assigning, one can generally use the same syntax and structure
as when feeding that field's value in a <code>put</code> operation.
</p>


<h3 id="single-field-value">Single value field</h3>
<h4 id="single-field-value">Single value field</h4>
<pre>
field title type string {
indexing: summary
Expand All @@ -543,7 +543,7 @@ <h3 id="single-field-value">Single value field</h3>
{% endhighlight %}</pre>


<h3 id="tensor-field">Tensor field</h3>
<h4 id="tensor-field">Tensor field</h4>
<pre>
field tensorfield type tensor(x{},y{}) {
indexing: attribute | summary
Expand All @@ -568,9 +568,9 @@ <h3 id="tensor-field">Tensor field</h3>
<p>This will fully replace the entire tensor stored in this field.</p>


<h3 id="<struct-field">Struct field</h3>
<h4 id="<struct-field">Struct field</h4>

<h4 id="replacing-all-fields-in-a-struct">Replacing all fields in a struct</h4>
<h5 id="replacing-all-fields-in-a-struct">Replacing all fields in a struct</h5>
<p>
A full struct is replaced by assigning an object of struct key/value pairs.
</p>
Expand All @@ -597,7 +597,7 @@ <h4 id="replacing-all-fields-in-a-struct">Replacing all fields in a struct</h4>
}
{% endhighlight %}</pre>

<h4 id="individual-struct-fields">Individual struct fields</h4>
<h5 id="individual-struct-fields">Individual struct fields</h5>
<p>
Individual struct fields are updated using <a href="#fieldpath">field path</a> syntax.
Refer to the <a href="schema-reference.html#struct-name">reference</a> for restrictions using structs.
Expand All @@ -617,7 +617,7 @@ <h4 id="individual-struct-fields">Individual struct fields</h4>
{% endhighlight %}</pre>


<h3 id="assign-map-field">Map field</h3>
<h4 id="assign-map-field">Map field</h4>
<p>
Individual map entries can be updated using <a href="document-field-path.html">field path</a> syntax.
The following declaration defines a <code>map</code> where the <code>key</code> is an Integer
Expand Down Expand Up @@ -654,7 +654,7 @@ <h3 id="assign-map-field">Map field</h3>
Refer to the <a href="schema-reference.html#map">reference</a> for restrictions using maps.
</p>

<h4 id="map-to-primitive-value">Map to primitive value</h4>
<h5 id="map-to-primitive-value">Map to primitive value</h5>
<pre>
field my_food_scores type map&lt;string, string&gt; {
indexing: summary
Expand All @@ -671,7 +671,7 @@ <h4 id="map-to-primitive-value">Map to primitive value</h4>
}
{% endhighlight %}</pre>

<h4 id="map-to-struct">Map to struct</h4>
<h5 id="map-to-struct">Map to struct</h5>
<pre>
struct contact_info {
field phone_number type string {}
Expand All @@ -696,9 +696,9 @@ <h4 id="map-to-struct">Map to struct</h4>
{% endhighlight %}</pre>


<h3 id="array-field">Array field</h3>
<h4 id="array-field">Array field</h4>

<h4 id="array-of-primitive-values">Array of primitive values</h4>
<h5 id="array-of-primitive-values">Array of primitive values</h5>
<pre>
field ingredients type array&lt;string&gt; {
indexing: summary
Expand Down Expand Up @@ -745,7 +745,7 @@ <h4 id="array-of-primitive-values">Array of primitive values</h4>
or <a href="#match">match</a> syntax.
</p>

<h4 id="array-of-struct">Array of struct</h4>
<h5 id="array-of-struct">Array of struct</h5>
<p>
Refer to the reference for restrictions using
<a href="schema-reference.html#array">array of structs</a>.
Expand Down Expand Up @@ -792,7 +792,7 @@ <h4 id="array-of-struct">Array of struct</h4>
{% endhighlight %}</pre>


<h3 id="weighted-set-field">Weighted set field</h3>
<h4 id="weighted-set-field">Weighted set field</h4>
<p>
Adding new elements to a weighted set can be done using <a href="#add-weighted-set">add</a>, or
by assigning with <code>field{key}</code> syntax. Example of the latter:
Expand Down Expand Up @@ -830,7 +830,7 @@ <h3 id="weighted-set-field">Weighted set field</h3>
</p>


<h3 id="clearing-a-field">Clearing a field</h3>
<h4 id="clearing-a-field">Clearing a field</h4>
<p>To clear a field, assign a <code>null</code> value to it.</p>
<pre>{% highlight json %}
{
Expand All @@ -845,13 +845,13 @@ <h3 id="clearing-a-field">Clearing a field</h3>



<h2 id="add">add</h2>
<h3 id="add">add</h3>
<p>
<code>add</code> is used to add entries to arrays, weighted sets or to the mapped dimensions of tensors.
</p>


<h3 id="add-array-elements">Adding array elements</h3>
<h4 id="add-array-elements">Adding array elements</h4>
<p>
The added entries are appended to the end of the array in the order specified.
</p>
Expand All @@ -875,7 +875,7 @@ <h3 id="add-array-elements">Adding array elements</h3>
{% endhighlight %}</pre>


<h3 id="add-weighted-set">Add weighted set entries</h3>
<h4 id="add-weighted-set">Add weighted set entries</h4>
<p>
Add weighted set elements by using a JSON key/value syntax,
where the value is the weight of the element.
Expand Down Expand Up @@ -910,7 +910,7 @@ <h3 id="add-weighted-set">Add weighted set entries</h3>
{% endhighlight %}</pre>


<h3 id="tensor-add">Add tensor cells</h3>
<h4 id="tensor-add">Add tensor cells</h4>
<p>
Add cells to mapped or mixed tensors. Invalid for tensors with only indexed
dimensions. Adding a cell that already exists will overwrite the cell value with the new value.
Expand Down Expand Up @@ -982,7 +982,7 @@ <h3 id="tensor-add">Add tensor cells</h3>



<h2 id="composite-remove">remove</h2>
<h3> id="composite-remove">remove</h3>
<p>Remove elements from weighted sets, maps and tensors with <code>remove</code>.</p>

<h4 id="weighted-set-field-remove">Weighted set field</h4>
Expand Down Expand Up @@ -1080,7 +1080,7 @@ <h4 id="tensor-remove">Tensor field</h4>



<h2 id="arithmetic">Arithmetic</h2>
<h3 id="arithmetic">Arithmetic</h3>
<p>
The four arithmetic operators <code>increment</code>, <code>decrement</code>,
<code>multiply</code> and <code>divide</code> are used to modify <em>single
Expand All @@ -1105,7 +1105,7 @@ <h2 id="arithmetic">Arithmetic</h2>



<h2 id="match">match</h2>
<h3 id="match">match</h3>
<p>
If an arithmetic operation is to be done for a specific key
in a <em>weighted set or array</em>, use the <code>match</code> operation:
Expand Down Expand Up @@ -1139,7 +1139,7 @@ <h2 id="match">match</h2>



<h2 id="tensor-modify">Modify tensors</h2>
<h3 id="tensor-modify">Modify tensors</h3>
<p>
Individual cells in tensors can be modified using the <code>modify</code> update.
The cells are modified according to the given operation:
Expand Down Expand Up @@ -1238,7 +1238,7 @@ <h2 id="tensor-modify">Modify tensors</h2>



<h2 id="fieldpath">fieldpath</h2>
<h3 id="fieldpath">fieldpath</h3>
<p>
Fieldpath is for accessing fields within composite structures -
for structures that are not part of index or attribute,
Expand Down

0 comments on commit 166c54f

Please sign in to comment.