Skip to content

Commit

Permalink
Fix fuzzy query rewrite parameter and add test (#561)
Browse files Browse the repository at this point in the history
Co-authored-by: Theo N. Truong <[email protected]>
  • Loading branch information
kolchfa-aws and nhtruong authored Sep 9, 2024
1 parent 5cd57c4 commit 49f7d99
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed content-type for `/hot_threads` ([#543](https://github.com/opensearch-project/opensearch-api-specification/pull/543))
- Fixed `/_cluster/settings` returning flat results ([#545](https://github.com/opensearch-project/opensearch-api-specification/pull/545))
- Fixed missing fields in `_cat` API ([#551](https://github.com/opensearch-project/opensearch-api-specification/pull/551))
- Fixed `geo_distance` query spec ([#561](https://github.com/opensearch-project/opensearch-api-specification/pull/561))
- Fixed `geo_bounding_box` and `geo_shape` queries ([#531](https://github.com/opensearch-project/opensearch-api-specification/pull/531))

### Security
Expand Down
7 changes: 7 additions & 0 deletions spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ components:
- id
MultiTermQueryRewrite:
type: string
enum:
- constant_score
- constant_score_boolean
- scoring_boolean
- top_terms_N
- top_terms_blended_freqs_N
- top_terms_boost_N
Fuzziness:
oneOf:
- type: string
Expand Down
56 changes: 56 additions & 0 deletions tests/default/_core/search/query/fuzzy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with fuzzy query.
prologues:
- path: /movies
method: PUT
request:
payload:
mappings:
properties:
title:
type: text
- path: /movies/_doc/1
method: POST
parameters:
refresh: true
request:
payload:
title: Brave
status: [201]
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Search for documents using a fuzzy query.
path: /{index}/_search
parameters:
index: movies
method: GET
request:
payload:
query:
fuzzy:
title:
value: bake
fuzziness: 2
max_expansions: 40
prefix_length: 0
transpositions: true
rewrite: constant_score
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: movies
_score: 1
_source:
title: Brave

0 comments on commit 49f7d99

Please sign in to comment.