-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ContextSuggester: Adding couple of tests to catch more bugs
A bunch of minor fixes have been included here, especially due to wrongly parsed mappings. Also using assertions resulted in an NPE because they were disabled in the distribution. Closes #5525
- Loading branch information
Showing
6 changed files
with
534 additions
and
47 deletions.
There are no files selected for viewing
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,219 @@ | ||
# This test creates one huge mapping in the setup | ||
# Every test should use its own field to make sure it works | ||
|
||
setup: | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
test: | ||
"properties": | ||
"suggest_context": | ||
"type" : "completion" | ||
"context": | ||
"color": | ||
"type" : "category" | ||
"suggest_context_default_hardcoded": | ||
"type" : "completion" | ||
"context": | ||
"color": | ||
"type" : "category" | ||
"default" : "red" | ||
"suggest_context_default_path": | ||
"type" : "completion" | ||
"context": | ||
"color": | ||
"type" : "category" | ||
"default" : "red" | ||
"path" : "color" | ||
"suggest_geo": | ||
"type" : "completion" | ||
"context": | ||
"location": | ||
"type" : "geo" | ||
|
||
--- | ||
"Simple context suggestion should work": | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 1 | ||
body: | ||
suggest_context: | ||
input: "Hoodie red" | ||
context: | ||
color: "red" | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 2 | ||
body: | ||
suggest_context: | ||
input: "Hoodie blue" | ||
context: | ||
color: "blue" | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
suggest: | ||
body: | ||
result: | ||
text: "hoo" | ||
completion: | ||
field: suggest_context | ||
context: | ||
color: "red" | ||
|
||
- match: {result.0.options.0.text: "Hoodie red" } | ||
|
||
--- | ||
"Hardcoded category value should work": | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 1 | ||
body: | ||
suggest_context_default_hardcoded: | ||
input: "Hoodie red" | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 2 | ||
body: | ||
suggest_context_default_hardcoded: | ||
input: "Hoodie blue" | ||
context: | ||
color: "blue" | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
suggest: | ||
body: | ||
result: | ||
text: "hoo" | ||
completion: | ||
field: suggest_context_default_hardcoded | ||
context: | ||
color: "red" | ||
|
||
- length: { result: 1 } | ||
- length: { result.0.options: 1 } | ||
- match: { result.0.options.0.text: "Hoodie red" } | ||
|
||
|
||
--- | ||
"Category suggest context default path should work": | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 1 | ||
body: | ||
suggest_context_default_path: | ||
input: "Hoodie red" | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 2 | ||
body: | ||
suggest_context_default_path: | ||
input: "Hoodie blue" | ||
color: "blue" | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
suggest: | ||
body: | ||
result: | ||
text: "hoo" | ||
completion: | ||
field: suggest_context_default_path | ||
context: | ||
color: "red" | ||
|
||
- length: { result: 1 } | ||
- length: { result.0.options: 1 } | ||
- match: { result.0.options.0.text: "Hoodie red" } | ||
|
||
- do: | ||
suggest: | ||
body: | ||
result: | ||
text: "hoo" | ||
completion: | ||
field: suggest_context_default_path | ||
context: | ||
color: "blue" | ||
|
||
- length: { result: 1 } | ||
- length: { result.0.options: 1 } | ||
- match: { result.0.options.0.text: "Hoodie blue" } | ||
|
||
|
||
--- | ||
"Geo suggest should work": | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 1 | ||
body: | ||
suggest_geo: | ||
input: "Hotel Marriot in Amsterdam" | ||
context: | ||
location: | ||
lat : 52.22 | ||
lon : 4.53 | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 2 | ||
body: | ||
suggest_geo: | ||
input: "Hotel Marriot in Berlin" | ||
context: | ||
location: | ||
lat : 53.31 | ||
lon : 13.24 | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
suggest: | ||
body: | ||
result: | ||
text: "hote" | ||
completion: | ||
field: suggest_geo | ||
context: | ||
location: | ||
lat : 52.22 | ||
lon : 4.53 | ||
|
||
- length: { result: 1 } | ||
- length: { result.0.options: 1 } | ||
- match: { result.0.options.0.text: "Hotel Marriot in Amsterdam" } | ||
|
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
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
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
Oops, something went wrong.