@@ -42,6 +42,18 @@ describe("parse", () => {
42
42
} ) ;
43
43
} ) ;
44
44
45
+ it ( "parses search POST request given in a single line" , async ( ) => {
46
+ const req = await parseRequest ( `POST /my-index/_search { "size": 5 }` ) ;
47
+ expect ( req ) . toMatchObject ( {
48
+ api : "search" ,
49
+ params : { index : "my-index" } ,
50
+ method : "POST" ,
51
+ url : "/my-index/_search" ,
52
+ path : "/my-index/_search" ,
53
+ body : { size : 5 } ,
54
+ } ) ;
55
+ } ) ;
56
+
45
57
it ( "parses a complex sequence of requests" , async ( ) => {
46
58
const reqs = await parseRequests ( `PUT /customer/_doc/1?foo=bar
47
59
{
@@ -73,11 +85,11 @@ POST /_bulk?foo=bar
73
85
{ "name": "John\\nDoe" }
74
86
75
87
76
- GET /customer/_doc/1
88
+ GET /{ customer} /_doc/1
77
89
78
90
POST _nodes/reload_secure_settings\n{\n "reload_secure_settings": "s3cr3t" <1>\n}
79
91
80
- GET my_index/_analyze <3>\n{\n "field": "text",\n "text": "The quick Brown Foxes."\n}
92
+ GET { my_index} /_analyze <3>\n{\n "field": "text",\n "text": "The quick Brown Foxes."\n}
81
93
82
94
POST\n_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update\n{\n "description": "Snapshot 1",\n "retain": true\n}
83
95
` ) ;
@@ -152,11 +164,11 @@ POST\n_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update\n
152
164
} ) ;
153
165
expect ( reqs [ 7 ] ) . toMatchObject ( {
154
166
api : "get" ,
155
- params : { index : "customer" , id : "1" } ,
167
+ params : { index : "{ customer} " , id : "1" } ,
156
168
method : "GET" ,
157
- url : "/customer /_doc/1" ,
158
- path : "/customer/_doc/1" ,
159
- rawPath : "/customer /_doc/1" ,
169
+ url : "/%7Bcustomer%7D /_doc/1" ,
170
+ path : "/{ customer} /_doc/1" ,
171
+ rawPath : "/%7Bcustomer%7D /_doc/1" ,
160
172
} ) ;
161
173
expect ( reqs [ 8 ] ) . toMatchObject ( {
162
174
api : "nodes.reload_secure_settings" ,
@@ -169,11 +181,11 @@ POST\n_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update\n
169
181
} ) ;
170
182
expect ( reqs [ 9 ] ) . toMatchObject ( {
171
183
api : "indices.analyze" ,
172
- params : { index : "my_index" } ,
184
+ params : { index : "{ my_index} " } ,
173
185
method : "GET" ,
174
- url : "/my_index /_analyze" ,
175
- path : "/my_index/_analyze" ,
176
- rawPath : "/my_index /_analyze" ,
186
+ url : "/%7Bmy_index%7D /_analyze" ,
187
+ path : "/{ my_index} /_analyze" ,
188
+ rawPath : "/%7Bmy_index%7D /_analyze" ,
177
189
body : { field : "text" , text : "The quick Brown Foxes." } ,
178
190
} ) ;
179
191
expect ( reqs [ 10 ] ) . toMatchObject ( {
0 commit comments