-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for analyzer validilty on derived field
Signed-off-by: Rishabh Maurya <[email protected]>
- Loading branch information
1 parent
c262f17
commit 4ffd4d5
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
...esources/rest-api-spec/test/painless/derived_fields/50_derived_field_default_analyzer.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
"Test default index analyzer simple is applied on derived fields": | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index.analysis.analyzer.default.type: simple | ||
mappings: | ||
properties: | ||
text: | ||
type: text | ||
json_field: | ||
type: text | ||
derived: | ||
derived_text: | ||
type: text | ||
script: "emit(params._source[\"text\"])" | ||
derived_object: | ||
type: object | ||
properties: | ||
array_of_text: text | ||
script: "emit(params._source[\"json_field\"])" | ||
source_indexed_field: "json_field" | ||
|
||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
body: { | ||
text: "Email: [email protected], Visit https://example.com for more info.", | ||
json_field: "{\"array_of_text\": [\"Email: [email protected], Visit https://example.com for more info.\", \"Email: [email protected], Visit https://example.com for more info.\"]}}" | ||
} | ||
|
||
- do: | ||
indices.refresh: | ||
index: [test] | ||
- do: | ||
search: | ||
index: test | ||
q: "derived_text:example.com" | ||
analyzer: standard | ||
|
||
- match: { hits.total.value: 0 } | ||
|
||
- do: | ||
search: | ||
index: test | ||
q: "derived_text:example.com" | ||
analyzer: simple | ||
|
||
- match: { hits.total.value: 1 } | ||
|
||
--- | ||
"Test default index analyzer standard is applied on derived fields": | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index.analysis.analyzer.default.type: standard | ||
mappings: | ||
properties: | ||
text: | ||
type: text | ||
json_field: | ||
type: text | ||
derived: | ||
derived_text: | ||
type: text | ||
script: "emit(params._source[\"text\"])" | ||
derived_object: | ||
type: object | ||
properties: | ||
array_of_text: text | ||
script: "emit(params._source[\"json_field\"])" | ||
source_indexed_field: "json_field" | ||
|
||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
body: { | ||
text: "Email: [email protected], Visit https://example.com for more info.", | ||
json_field: "{\"array_of_text\": [\"Email: [email protected], Visit https://example.com for more info.\", \"Email: [email protected], Visit https://example.com for more info.\"]}}" | ||
} | ||
|
||
- do: | ||
indices.refresh: | ||
index: [test] | ||
- do: | ||
search: | ||
index: test | ||
q: "derived_object.array_of_text:example.com" | ||
analyzer: standard | ||
|
||
- match: { hits.total.value: 1 } | ||
|
||
- do: | ||
search: | ||
index: test | ||
q: "derived_object.array_of_text:example.com" | ||
analyzer: simple | ||
|
||
- match: { hits.total.value: 1 } |