Skip to content

Commit

Permalink
Remove the ability to index or query context suggestions without context
Browse files Browse the repository at this point in the history
This is a follow up of elastic#30712 that removes the ability to index or query
and context enabled completion field without context.

Relates elastic#30712
  • Loading branch information
jimczi committed May 31, 2018
1 parent 46e8d97 commit 32f3a45
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 36 deletions.
7 changes: 7 additions & 0 deletions docs/reference/migration/migrate_7_0/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,10 @@ for a particular index with the index setting `index.max_regex_length`.

Search requests with extra content after the main object will no longer be accepted
by the `_search` endpoint. A parsing exception will be thrown instead.

==== Context Completion Suggester

The ability to query and index context enabled suggestions without context,
deprecated in 6.x, has been removed. Context enabled suggestion queries
without contexts have to visit every suggestion, which degrades the search performance
considerably.
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,10 @@ setup:
- match: { suggest.result.0.options.0.text: "foo" }

---
"Indexing and Querying without contexts is deprecated":
"Indexing and Querying without contexts is forbidden":
- skip:
version: " - 6.99.99"
reason: this feature was deprecated in 7.0
features: "warnings"
reason: this feature was removed in 7.0

- do:
index:
Expand All @@ -359,8 +358,7 @@ setup:
color: "blue"

- do:
warnings:
- "The ability to index a suggestion with no context on a context enabled completion field is deprecated and will be removed in the next major release."
catch: /Contexts are mandatory in context enabled completion field \[suggest_context\]/
index:
index: test
type: test
Expand All @@ -373,8 +371,7 @@ setup:
indices.refresh: {}

- do:
warnings:
- "The ability to query with no context on a context enabled completion field is deprecated and will be removed in the next major release."
catch: /Missing mandatory contexts in context query/
search:
body:
suggest:
Expand All @@ -383,11 +380,8 @@ setup:
completion:
field: suggest_context

- length: { suggest.result: 1 }

- do:
warnings:
- "The ability to query with no context on a context enabled completion field is deprecated and will be removed in the next major release."
catch: /Missing mandatory contexts in context query/
search:
body:
suggest:
Expand All @@ -397,11 +391,8 @@ setup:
field: suggest_context
contexts: {}

- length: { suggest.result: 1 }

- do:
warnings:
- "The ability to query with no context on a context enabled completion field is deprecated and will be removed in the next major release."
catch: /Missing mandatory contexts in context query/
search:
body:
suggest:
Expand All @@ -411,5 +402,3 @@ setup:
field: suggest_multi_contexts
contexts:
location: []

- length: { suggest.result: 1 }
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ setup:
"type" : "category"

- do:
warnings:
- "The ability to index a suggestion with no context on a context enabled completion field is deprecated and will be removed in the next major release."
bulk:
refresh: true
index: test
Expand All @@ -29,18 +27,12 @@ setup:
- '{"index": {}}'
- '{"title": "Elasticsearch in Action", "suggestions": {"input": "ELK in Action", "contexts": {"format": "ebook"}}}'
- '{"index": {}}'
- '{"title": "Elasticsearch - The Definitive Guide", "suggestions": {"input": ["Elasticsearch in Action"]}}'
- '{"title": "Elasticsearch - The Definitive Guide", "suggestions": {"input": ["Elasticsearch in Action"], "contexts": {"format": "ebook"}}}'

---
"Test typed keys parameter for suggesters":
- skip:
version: " - 6.99.99"
reason: queying a context suggester with no context was deprecated in 7.0
features: "warnings"

- do:
warnings:
- "The ability to query with no context on a context enabled completion field is deprecated and will be removed in the next major release."
search:
typed_keys: true
body:
Expand All @@ -51,10 +43,6 @@ setup:
term_suggester:
term:
field: title
completion_suggester:
prefix: "Elastic"
completion:
field: suggestions
context_suggester:
prefix: "Elastic"
completion:
Expand All @@ -66,6 +54,5 @@ setup:
field: title

- is_true: suggest.term#term_suggester
- is_true: suggest.completion#completion_suggester
- is_true: suggest.completion#context_suggester
- is_true: suggest.phrase#phrase_suggester
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private class TypedContextField extends ContextSuggestField {
private final ParseContext.Document document;

TypedContextField(String name, String value, int weight, Map<String, Set<CharSequence>> contexts,
ParseContext.Document document) {
ParseContext.Document document) {
super(name, value, weight);
this.contexts = contexts;
this.document = document;
Expand All @@ -150,8 +150,7 @@ protected Iterable<CharSequence> contexts() {
}
}
if (typedContexts.isEmpty()) {
DEPRECATION_LOGGER.deprecated("The ability to index a suggestion with no context on a context enabled completion field" +
" is deprecated and will be removed in the next major release.");
throw new IllegalArgumentException("Contexts are mandatory in context enabled completion field [" + name + "]");
}
return typedContexts;
}
Expand Down Expand Up @@ -186,8 +185,7 @@ public ContextQuery toContextQuery(CompletionQuery query, Map<String, List<Conte
}
}
if (hasContext == false) {
DEPRECATION_LOGGER.deprecated("The ability to query with no context on a context enabled completion field is deprecated " +
"and will be removed in the next major release.");
throw new IllegalArgumentException("Missing mandatory contexts in context query");
}
return typedContextQuery;
}
Expand Down

0 comments on commit 32f3a45

Please sign in to comment.