You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/search-application/apis/put-search-application.asciidoc
+90-1Lines changed: 90 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,21 @@ The <<search-template,search template>> associated with this search application.
49
49
- The template may be modified with subsequent <<put-search-application,put search application>> requests.
50
50
- If no template is specified when creating a search application, or if a template is removed from a search application, we use the <<query-string-query-ex-request,query_string>> defined in the template examples as a default.
51
51
- This template will be used by the <<search-application-search,search application search>> API to execute searches.
52
+
- The template accepts an optional `dictionary` parameter which defines a https://json-schema.org[JSON schema] used for validating parameters sent to the <<search-application-search,search application search>> API.
53
+
54
+
.Properties of `<template>`
55
+
[%collapsible%open]
56
+
=====
57
+
58
+
`script`::
59
+
(Required, object)
60
+
The associated mustache template.
61
+
62
+
`dictionary`::
63
+
(Optional, object)
64
+
The dictionary used to validate the parameters used with the <<search-application-search, search application search>> API. The dictionary must be a valid JSON schema.
65
+
If `dictionary` is not specified, then the parameters will not be validated before being applied in the template.
66
+
=====
52
67
====
53
68
54
69
@@ -85,12 +100,69 @@ PUT _application/search_application/my-app?create
85
100
"query_string": "*",
86
101
"default_field": "*"
87
102
}
103
+
},
104
+
"dictionary": {
105
+
"properties": {
106
+
"query_string": {
107
+
"type": "string"
108
+
},
109
+
"default_field": {
110
+
"type": "string",
111
+
"enum": [
112
+
"title",
113
+
"description"
114
+
]
115
+
},
116
+
"additionalProperties": false
117
+
},
118
+
"required": [
119
+
"query_string"
120
+
]
88
121
}
89
122
}
90
123
}
91
124
----
92
125
// TEST[skip:TBD]
93
126
127
+
When the above `dictionary` parameter is specified, the <<search-application-search, search application search>> API will perform the following parameter validation:
128
+
129
+
* It accepts only the `query_string` and `default_field` parameters
130
+
* It verifies that `query_string` and `default_field` are both strings
131
+
* It accepts `default_field` only if it takes the values `title` or `description`
132
+
133
+
If the parameters are not valid, the the <<search-application-search, search application search>> API will return an error.
134
+
[source,console]
135
+
----
136
+
POST _application/search_application/my-app/_search
137
+
{
138
+
"params": {
139
+
"default_field": "author",
140
+
"query_string": "Jane"
141
+
}
142
+
}
143
+
----
144
+
// TEST[skip:TBD]
145
+
146
+
In the above example, the value of the `default_field` parameter is not valid, therefore Elasticsearch will return an error:
147
+
148
+
[source,console-result]
149
+
----
150
+
{
151
+
"error": {
152
+
"root_cause": [
153
+
{
154
+
"type": "validation_exception",
155
+
"reason": "Validation Failed: 1: $.default_field: does not have a value in the enumeration [title, description];"
156
+
}
157
+
],
158
+
"type": "validation_exception",
159
+
"reason": "Validation Failed: 1: $.default_field: does not have a value in the enumeration [title, description];"
160
+
},
161
+
"status": 400
162
+
}
163
+
----
164
+
// TEST[skip:TBD]
165
+
94
166
The following example creates or updates an existing Search Application called `my-app`:
95
167
96
168
[source,console]
@@ -112,9 +184,26 @@ PUT _application/search_application/my-app
0 commit comments