Skip to content

Commit

Permalink
Fix: _update_by_query with a tem.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Jul 26, 2024
1 parent 6fd9afe commit 396fb97
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 89 deletions.
31 changes: 15 additions & 16 deletions spec/schemas/_common.query_dsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ components:
Returns documents that contain an exact term in a provided field.
To return a document, the query term must exactly match the queried field's value, including whitespace and capitalization.
type: object
additionalProperties:
$ref: '#/components/schemas/TermQuery'
additionalProperties: true
minProperties: 1
maxProperties: 1
terms:
Expand Down Expand Up @@ -1811,20 +1810,20 @@ components:
required:
- big
- little
TermQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
- type: object
properties:
value:
$ref: '_common.yaml#/components/schemas/FieldValue'
case_insensitive:
description: |-
Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`.
When `false`, the case sensitivity of matching depends on the underlying field's mapping.
type: boolean
required:
- value
# TermQuery:
# allOf:
# - $ref: '#/components/schemas/QueryBase'
# - type: object
# properties:
# value:
# $ref: '_common.yaml#/components/schemas/FieldValue'
# case_insensitive:
# description: |-
# Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`.
# When `false`, the case sensitivity of matching depends on the underlying field's mapping.
# type: boolean
# required:
# - value
TermsQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
Expand Down
3 changes: 1 addition & 2 deletions spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ components:
Specifies any named parameters that are passed into the script as variables.
Use parameters instead of hard-coded values to decrease compile time.
type: object
additionalProperties:
type: object
additionalProperties: true
StoredScriptId:
allOf:
- $ref: '#/components/schemas/ScriptBase'
Expand Down
71 changes: 0 additions & 71 deletions tests/_core/reindex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,7 @@ epilogues:
- path: /videos
method: DELETE
status: [200, 404]
- path: /_ingest/pipeline/transform-and-count
method: DELETE
status: [200, 404]
prologues:
- path: /_ingest/pipeline/transform-and-count
method: PUT
request_body:
payload:
description: |
Splits the `title`` field into a `words` list.
Computes the length of the title field and stores it in a new `length` field.
Removes the `year` field.
processors:
- split:
field: title
separator: '\s+'
target_field: words
- script:
lang: painless
source: ctx.length = ctx.words.length
- remove:
field: year
- path: /{index}/_doc
method: POST
parameters:
Expand Down Expand Up @@ -135,56 +114,6 @@ chapters:
status: 200
payload:
total: 1
- synopsis: Transform documents using a pipeline.
path: /_reindex
method: POST
request_body:
payload:
source:
index: movies
dest:
index: videos
pipeline: transform-and-count
response:
status: 200
- synopsis: Refresh the index.
path: /{index}/_refresh
method: POST
parameters:
index: videos
- synopsis: Get all videos.
path: /{index}/_search
method: POST
parameters:
index: videos
request_body:
payload:
query:
match_all: {}
response:
status: 200
payload:
hits:
hits:
- _index: videos
_source:
words:
- Beauty
- and
- the
# eslint-disable-next-line yml/sort-sequence-values
- Beast
length: 4
title: Beauty and the Beast
- synopsis: Update documents in the current index.
path: /{index}/_update_by_query
method: POST
parameters:
index: videos
response:
status: 200
payload:
updated: 1
- synopsis: Reindex from movies to films with all options.
path: /_reindex
method: POST
Expand Down
84 changes: 84 additions & 0 deletions tests/_core/reindex/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test reindex with a Search pipeline.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
- path: /videos
method: DELETE
status: [200, 404]
- path: /_ingest/pipeline/transform-and-count
method: DELETE
status: [200, 404]
prologues:
- path: /_ingest/pipeline/transform-and-count
method: PUT
request_body:
payload:
description: |
Splits the `title`` field into a `words` list.
Computes the length of the title field and stores it in a new `length` field.
Removes the `year` field.
processors:
- split:
field: title
separator: '\s+'
target_field: words
- script:
lang: painless
source: ctx.length = ctx.words.length
- remove:
field: year
- path: /{index}/_doc
method: POST
parameters:
index: movies
refresh: true
request_body:
payload:
title: Beauty and the Beast
year: 91
status: [201]
chapters:
- synopsis: Transform documents using a pipeline.
path: /_reindex
method: POST
request_body:
payload:
source:
index: movies
dest:
index: videos
pipeline: transform-and-count
response:
status: 200
- synopsis: Refresh the index.
path: /{index}/_refresh
method: POST
parameters:
index: videos
- synopsis: Get all videos.
path: /{index}/_search
method: POST
parameters:
index: videos
request_body:
payload:
query:
match_all: {}
response:
status: 200
payload:
hits:
hits:
- _index: videos
_source:
words:
- Beauty
- and
- the
# eslint-disable-next-line yml/sort-sequence-values
- Beast
length: 4
title: Beauty and the Beast
48 changes: 48 additions & 0 deletions tests/indices/update_by_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test reindex.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
prologues:
- path: /{index}/_doc
method: POST
parameters:
index: movies
refresh: true
request_body:
payload:
title: Beauty and the Beast
year: 91
status: [201]
chapters:
- synopsis: Update documents in the index.
path: /{index}/_update_by_query
method: POST
parameters:
index: movies
refresh: true
response:
status: 200
payload:
updated: 1
- synopsis: Update documents in the index (script).
path: /{index}/_update_by_query
method: POST
parameters:
index: movies
request_body:
payload:
query:
term:
year: 91
script:
source: ctx._source.year += params.century
lang: painless
params:
century: 1900
response:
status: 200
payload:
updated: 1

0 comments on commit 396fb97

Please sign in to comment.