Skip to content

Commit

Permalink
Added tests for /_analyze and /{index}/_analyze.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Aug 21, 2024
1 parent e306f86 commit cfe5e2b
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 0 deletions.
98 changes: 98 additions & 0 deletions tests/default/_core/analyze.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test /_analyze.
epilogues: []
prologues: []
chapters:
- synopsis: Analyze text.
path: /_analyze
method: POST
request:
payload:
analyzer: standard
text: Moneyball, directed by Bennett Miller
response:
status: 200
payload:
tokens:
- token: moneyball
start_offset: 0
end_offset: 9
position: 0
- synopsis: Analyze text as a multi-value field.
path: /_analyze
method: GET
request:
payload:
analyzer: standard
text:
- Drive, directed by Nicolas Winding Refn
- Moneyball, directed by Bennett Miller
response:
status: 200
payload:
tokens:
- token: moneyball
start_offset: 0
end_offset: 9
position: 0
- synopsis: Apply a filter.
path: /_analyze
method: GET
request:
payload:
tokenizer: keyword
filter:
- uppercase
text: Moneyball
response:
status: 200
payload:
tokens:
- token: MONEYBALL
type: word
start_offset: 0
end_offset: 9
position: 0
- synopsis: Apply a character filter.
path: /_analyze
method: GET
request:
payload:
tokenizer: keyword
filter:
- lowercase
char_filter:
- html_strip
text: <b>Moneyball</b>
response:
status: 200
payload:
tokens:
- token: moneyball
type: word
start_offset: 3
end_offset: 16
position: 0
- synopsis: Combine a lowercase translation with a stop filter.
path: /_analyze
method: GET
request:
payload:
tokenizer: whitespace
filter:
- lowercase
- type: stop
stopwords:
- in
- to
text: Moneyball directed by Bennett Miller
response:
status: 200
payload:
tokens:
- token: moneyball
type: word
start_offset: 0
end_offset: 9
position: 0
51 changes: 51 additions & 0 deletions tests/default/indices/analyze.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test /{index}/_analyze.
prologues:
- path: /movies
method: PUT
request:
payload:
settings:
analysis:
analyzer:
default:
type: stop
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Analyze text.
path: /{index}/_analyze
method: POST
parameters:
index: movies
request:
payload:
text: a movie directed by Bennett Miller
response:
status: 200
payload:
tokens:
- token: movie
start_offset: 2
end_offset: 7
position: 1
- synopsis: Analyze text specifying an analyzer.
path: /{index}/_analyze
method: GET
parameters:
index: movies
request:
payload:
analyzer: standard
text: a movie directed by Bennett Miller
response:
status: 200
payload:
tokens:
- token: a
start_offset: 0
end_offset: 1
position: 0

0 comments on commit cfe5e2b

Please sign in to comment.