summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/search/suggest/completion
diff options
context:
space:
mode:
authorNilabh Sagar <nilabhsagar@gmail.com>2017-04-24 20:05:14 +0530
committerNik Everett <nik9000@gmail.com>2017-04-24 10:35:14 -0400
commit373edee29a676444c0f423b9ee202fb0735d3ccd (patch)
tree83d371f07090f0d4910814f4033d8ab8bde3e908 /core/src/main/java/org/elasticsearch/search/suggest/completion
parent931198688c2d34555fb7d82a0d2cf34feea70f1d (diff)
Provide informative error message in case of unknown suggestion context. (#24241)
Provide a list of available contexts when you send an unknown context to the completion suggester.
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/suggest/completion')
-rw-r--r--core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java
index 0cac17dbb8..bbefbf41b8 100644
--- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java
+++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java
@@ -81,7 +81,9 @@ public class ContextMappings implements ToXContent {
public ContextMapping get(String name) {
ContextMapping contextMapping = contextNameMap.get(name);
if (contextMapping == null) {
- throw new IllegalArgumentException("Unknown context name[" + name + "], must be one of " + contextNameMap.size());
+ List<String> keys = new ArrayList<>(contextNameMap.keySet());
+ Collections.sort(keys);
+ throw new IllegalArgumentException("Unknown context name [" + name + "], must be one of " + keys.toString());
}
return contextMapping;
}