-
Notifications
You must be signed in to change notification settings - Fork 298
Expand file tree
/
Copy pathQueryRequest.java
More file actions
859 lines (748 loc) · 25.3 KB
/
Copy pathQueryRequest.java
File metadata and controls
859 lines (748 loc) · 25.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.clients.elasticsearch.esql;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.RequestBase;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.elasticsearch._types.query_dsl.QueryVariant;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.transport.Endpoint;
import co.elastic.clients.transport.endpoints.BinaryEndpoint;
import co.elastic.clients.transport.endpoints.BinaryResponse;
import co.elastic.clients.transport.endpoints.SimpleEndpoint;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.String;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------
// typedef: esql.query.Request
/**
* Run an ES|QL query.
* <p>
* Get search results for an ES|QL (Elasticsearch query language) query.
*
* @see <a href="../doc-files/api-spec.html#esql.query.Request">API
* specification</a>
*/
@JsonpDeserializable
public class QueryRequest extends RequestBase implements JsonpSerializable {
@Nullable
private final Boolean allowPartialResults;
@Nullable
private final Boolean columnar;
@Nullable
private final String delimiter;
@Nullable
private final Boolean dropNullColumns;
@Nullable
private final Query filter;
@Nullable
private final EsqlFormat format;
@Nullable
private final Boolean includeCcsMetadata;
@Nullable
private final Boolean includeExecutionMetadata;
@Nullable
private final String locale;
private final List<FieldValue> params;
@Nullable
private final Boolean profile;
@Nullable
private final String projectRouting;
private final String query;
private final Map<String, Map<String, TableValues>> tables;
// ---------------------------------------------------------------------------------------------
private QueryRequest(Builder builder) {
this.allowPartialResults = builder.allowPartialResults;
this.columnar = builder.columnar;
this.delimiter = builder.delimiter;
this.dropNullColumns = builder.dropNullColumns;
this.filter = builder.filter;
this.format = builder.format;
this.includeCcsMetadata = builder.includeCcsMetadata;
this.includeExecutionMetadata = builder.includeExecutionMetadata;
this.locale = builder.locale;
this.params = ApiTypeHelper.unmodifiable(builder.params);
this.profile = builder.profile;
this.projectRouting = builder.projectRouting;
this.query = ApiTypeHelper.requireNonNull(builder.query, this, "query");
this.tables = ApiTypeHelper.unmodifiable(builder.tables);
}
public static QueryRequest of(Function<Builder, ObjectBuilder<QueryRequest>> fn) {
return fn.apply(new Builder()).build();
}
/**
* If <code>true</code>, partial results will be returned if there are shard
* failures, but the query can continue to execute on other clusters and shards.
* If <code>false</code>, the query will fail if there are any failures.
* <p>
* To override the default behavior, you can set the
* <code>esql.query.allow_partial_results</code> cluster setting to
* <code>false</code>.
* <p>
* API name: {@code allow_partial_results}
*/
@Nullable
public final Boolean allowPartialResults() {
return this.allowPartialResults;
}
/**
* By default, ES|QL returns results as rows. For example, FROM returns each
* individual document as one row. For the JSON, YAML, CBOR and smile formats,
* ES|QL can return the results in a columnar fashion where one row represents
* all the values of a certain column in the results.
* <p>
* API name: {@code columnar}
*/
@Nullable
public final Boolean columnar() {
return this.columnar;
}
/**
* The character to use between values within a CSV row. Only valid for the CSV
* format.
* <p>
* API name: {@code delimiter}
*/
@Nullable
public final String delimiter() {
return this.delimiter;
}
/**
* Should columns that are entirely <code>null</code> be removed from the
* <code>columns</code> and <code>values</code> portion of the results? Defaults
* to <code>false</code>. If <code>true</code> then the response will include an
* extra section under the name <code>all_columns</code> which has the name of
* all columns.
* <p>
* API name: {@code drop_null_columns}
*/
@Nullable
public final Boolean dropNullColumns() {
return this.dropNullColumns;
}
/**
* Specify a Query DSL query in the filter parameter to filter the set of
* documents that an ES|QL query runs on.
* <p>
* API name: {@code filter}
*/
@Nullable
public final Query filter() {
return this.filter;
}
/**
* A short version of the Accept header, e.g. json, yaml.
* <p>
* <code>csv</code>, <code>tsv</code>, and <code>txt</code> formats will return
* results in a tabular format, excluding other metadata fields from the
* response.
* <p>
* API name: {@code format}
*/
@Nullable
public final EsqlFormat format() {
return this.format;
}
/**
* When set to <code>true</code> and performing a cross-cluster/cross-project
* query, the response will include an extra <code>_clusters</code> object with
* information about the clusters that participated in the search along with
* info such as shards count.
* <p>
* API name: {@code include_ccs_metadata}
*/
@Nullable
public final Boolean includeCcsMetadata() {
return this.includeCcsMetadata;
}
/**
* When set to <code>true</code>, the response will include an extra
* <code>_clusters</code> object with information about the clusters that
* participated in the search along with info such as shards count. This is
* similar to <code>include_ccs_metadata</code>, but it also returns metadata
* when the query is not CCS/CPS
* <p>
* API name: {@code include_execution_metadata}
*/
@Nullable
public final Boolean includeExecutionMetadata() {
return this.includeExecutionMetadata;
}
/**
* API name: {@code locale}
*/
@Nullable
public final String locale() {
return this.locale;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
*/
public final List<FieldValue> params() {
return this.params;
}
/**
* If provided and <code>true</code> the response will include an extra
* <code>profile</code> object with information on how the query was executed.
* This information is for human debugging and its format can change at any time
* but it can give some insight into the performance of each part of the query.
* <p>
* API name: {@code profile}
*/
@Nullable
public final Boolean profile() {
return this.profile;
}
/**
* Specifies a subset of projects to target using project metadata tags in a
* subset of Lucene query syntax. Allowed Lucene queries: the _alias tag and a
* single value (possibly wildcarded). Examples: _alias:my-project
* _alias:_origin _alias:<em>pr</em> Supported in serverless only.
* <p>
* API name: {@code project_routing}
*/
@Nullable
public final String projectRouting() {
return this.projectRouting;
}
/**
* Required - The ES|QL query API accepts an ES|QL query string in the query
* parameter, runs it, and returns the results.
* <p>
* API name: {@code query}
*/
public final String query() {
return this.query;
}
/**
* Tables to use with the LOOKUP operation. The top level key is the table name
* and the next level key is the column name.
* <p>
* API name: {@code tables}
*/
public final Map<String, Map<String, TableValues>> tables() {
return this.tables;
}
/**
* Serialize this object to JSON.
*/
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
if (this.columnar != null) {
generator.writeKey("columnar");
generator.write(this.columnar);
}
if (this.filter != null) {
generator.writeKey("filter");
this.filter.serialize(generator, mapper);
}
if (this.includeCcsMetadata != null) {
generator.writeKey("include_ccs_metadata");
generator.write(this.includeCcsMetadata);
}
if (this.includeExecutionMetadata != null) {
generator.writeKey("include_execution_metadata");
generator.write(this.includeExecutionMetadata);
}
if (this.locale != null) {
generator.writeKey("locale");
generator.write(this.locale);
}
if (ApiTypeHelper.isDefined(this.params)) {
generator.writeKey("params");
generator.writeStartArray();
for (FieldValue item0 : this.params) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (this.profile != null) {
generator.writeKey("profile");
generator.write(this.profile);
}
if (this.projectRouting != null) {
generator.writeKey("project_routing");
generator.write(this.projectRouting);
}
generator.writeKey("query");
generator.write(this.query);
if (ApiTypeHelper.isDefined(this.tables)) {
generator.writeKey("tables");
generator.writeStartObject();
for (Map.Entry<String, Map<String, TableValues>> item0 : this.tables.entrySet()) {
generator.writeKey(item0.getKey());
generator.writeStartObject();
if (item0.getValue() != null) {
for (Map.Entry<String, TableValues> item1 : item0.getValue().entrySet()) {
generator.writeKey(item1.getKey());
item1.getValue().serialize(generator, mapper);
}
}
generator.writeEnd();
}
generator.writeEnd();
}
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link QueryRequest}.
*/
public static class Builder extends RequestBase.AbstractBuilder<Builder> implements ObjectBuilder<QueryRequest> {
@Nullable
private Boolean allowPartialResults;
@Nullable
private Boolean columnar;
@Nullable
private String delimiter;
@Nullable
private Boolean dropNullColumns;
@Nullable
private Query filter;
@Nullable
private EsqlFormat format;
@Nullable
private Boolean includeCcsMetadata;
@Nullable
private Boolean includeExecutionMetadata;
@Nullable
private String locale;
@Nullable
private List<FieldValue> params;
@Nullable
private Boolean profile;
@Nullable
private String projectRouting;
private String query;
@Nullable
private Map<String, Map<String, TableValues>> tables;
public Builder() {
}
private Builder(QueryRequest instance) {
this.allowPartialResults = instance.allowPartialResults;
this.columnar = instance.columnar;
this.delimiter = instance.delimiter;
this.dropNullColumns = instance.dropNullColumns;
this.filter = instance.filter;
this.format = instance.format;
this.includeCcsMetadata = instance.includeCcsMetadata;
this.includeExecutionMetadata = instance.includeExecutionMetadata;
this.locale = instance.locale;
this.params = instance.params;
this.profile = instance.profile;
this.projectRouting = instance.projectRouting;
this.query = instance.query;
this.tables = instance.tables;
}
/**
* If <code>true</code>, partial results will be returned if there are shard
* failures, but the query can continue to execute on other clusters and shards.
* If <code>false</code>, the query will fail if there are any failures.
* <p>
* To override the default behavior, you can set the
* <code>esql.query.allow_partial_results</code> cluster setting to
* <code>false</code>.
* <p>
* API name: {@code allow_partial_results}
*/
public final Builder allowPartialResults(@Nullable Boolean value) {
this.allowPartialResults = value;
return this;
}
/**
* By default, ES|QL returns results as rows. For example, FROM returns each
* individual document as one row. For the JSON, YAML, CBOR and smile formats,
* ES|QL can return the results in a columnar fashion where one row represents
* all the values of a certain column in the results.
* <p>
* API name: {@code columnar}
*/
public final Builder columnar(@Nullable Boolean value) {
this.columnar = value;
return this;
}
/**
* The character to use between values within a CSV row. Only valid for the CSV
* format.
* <p>
* API name: {@code delimiter}
*/
public final Builder delimiter(@Nullable String value) {
this.delimiter = value;
return this;
}
/**
* Should columns that are entirely <code>null</code> be removed from the
* <code>columns</code> and <code>values</code> portion of the results? Defaults
* to <code>false</code>. If <code>true</code> then the response will include an
* extra section under the name <code>all_columns</code> which has the name of
* all columns.
* <p>
* API name: {@code drop_null_columns}
*/
public final Builder dropNullColumns(@Nullable Boolean value) {
this.dropNullColumns = value;
return this;
}
/**
* Specify a Query DSL query in the filter parameter to filter the set of
* documents that an ES|QL query runs on.
* <p>
* API name: {@code filter}
*/
public final Builder filter(@Nullable Query value) {
this.filter = value;
return this;
}
/**
* Specify a Query DSL query in the filter parameter to filter the set of
* documents that an ES|QL query runs on.
* <p>
* API name: {@code filter}
*/
public final Builder filter(Function<Query.Builder, ObjectBuilder<Query>> fn) {
return this.filter(fn.apply(new Query.Builder()).build());
}
/**
* Specify a Query DSL query in the filter parameter to filter the set of
* documents that an ES|QL query runs on.
* <p>
* API name: {@code filter}
*/
public final Builder filter(QueryVariant value) {
this.filter = value._toQuery();
return this;
}
/**
* A short version of the Accept header, e.g. json, yaml.
* <p>
* <code>csv</code>, <code>tsv</code>, and <code>txt</code> formats will return
* results in a tabular format, excluding other metadata fields from the
* response.
* <p>
* API name: {@code format}
*/
public final Builder format(@Nullable EsqlFormat value) {
this.format = value;
return this;
}
/**
* When set to <code>true</code> and performing a cross-cluster/cross-project
* query, the response will include an extra <code>_clusters</code> object with
* information about the clusters that participated in the search along with
* info such as shards count.
* <p>
* API name: {@code include_ccs_metadata}
*/
public final Builder includeCcsMetadata(@Nullable Boolean value) {
this.includeCcsMetadata = value;
return this;
}
/**
* When set to <code>true</code>, the response will include an extra
* <code>_clusters</code> object with information about the clusters that
* participated in the search along with info such as shards count. This is
* similar to <code>include_ccs_metadata</code>, but it also returns metadata
* when the query is not CCS/CPS
* <p>
* API name: {@code include_execution_metadata}
*/
public final Builder includeExecutionMetadata(@Nullable Boolean value) {
this.includeExecutionMetadata = value;
return this;
}
/**
* API name: {@code locale}
*/
public final Builder locale(@Nullable String value) {
this.locale = value;
return this;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
* <p>
* Adds all elements of <code>list</code> to <code>params</code>.
*/
public final Builder params(List<FieldValue> list) {
this.params = _listAddAll(this.params, list);
return this;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
* <p>
* Adds one or more values to <code>params</code>.
*/
public final Builder params(FieldValue value, FieldValue... values) {
this.params = _listAdd(this.params, value, values);
return this;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
* <p>
* Adds one or more values to <code>params</code>.
*/
public final Builder params(String value, String... values) {
this.params = _listAdd(this.params, FieldValue.of(value));
for (String v : values) {
_listAdd(this.params, FieldValue.of(v));
}
return this;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
* <p>
* Adds one or more values to <code>params</code>.
*/
public final Builder params(long value, long... values) {
this.params = _listAdd(this.params, FieldValue.of(value));
for (long v : values) {
_listAdd(this.params, FieldValue.of(v));
}
return this;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
* <p>
* Adds one or more values to <code>params</code>.
*/
public final Builder params(double value, double... values) {
this.params = _listAdd(this.params, FieldValue.of(value));
for (double v : values) {
_listAdd(this.params, FieldValue.of(v));
}
return this;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
* <p>
* Adds one or more values to <code>params</code>.
*/
public final Builder params(boolean value, boolean... values) {
this.params = _listAdd(this.params, FieldValue.of(value));
for (boolean v : values) {
_listAdd(this.params, FieldValue.of(v));
}
return this;
}
/**
* To avoid any attempts of hacking or code injection, extract the values in a
* separate list of parameters. Use question mark placeholders (?) in the query
* string for each of the parameters.
* <p>
* API name: {@code params}
* <p>
* Adds a value to <code>params</code> using a builder lambda.
*/
public final Builder params(Function<FieldValue.Builder, ObjectBuilder<FieldValue>> fn) {
return params(fn.apply(new FieldValue.Builder()).build());
}
/**
* If provided and <code>true</code> the response will include an extra
* <code>profile</code> object with information on how the query was executed.
* This information is for human debugging and its format can change at any time
* but it can give some insight into the performance of each part of the query.
* <p>
* API name: {@code profile}
*/
public final Builder profile(@Nullable Boolean value) {
this.profile = value;
return this;
}
/**
* Specifies a subset of projects to target using project metadata tags in a
* subset of Lucene query syntax. Allowed Lucene queries: the _alias tag and a
* single value (possibly wildcarded). Examples: _alias:my-project
* _alias:_origin _alias:<em>pr</em> Supported in serverless only.
* <p>
* API name: {@code project_routing}
*/
public final Builder projectRouting(@Nullable String value) {
this.projectRouting = value;
return this;
}
/**
* Required - The ES|QL query API accepts an ES|QL query string in the query
* parameter, runs it, and returns the results.
* <p>
* API name: {@code query}
*/
public final Builder query(String value) {
this.query = value;
return this;
}
/**
* Tables to use with the LOOKUP operation. The top level key is the table name
* and the next level key is the column name.
* <p>
* API name: {@code tables}
* <p>
* Adds all entries of <code>map</code> to <code>tables</code>.
*/
public final Builder tables(Map<String, Map<String, TableValues>> map) {
this.tables = _mapPutAll(this.tables, map);
return this;
}
/**
* Tables to use with the LOOKUP operation. The top level key is the table name
* and the next level key is the column name.
* <p>
* API name: {@code tables}
* <p>
* Adds an entry to <code>tables</code>.
*/
public final Builder tables(String key, Map<String, TableValues> value) {
this.tables = _mapPut(this.tables, key, value);
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link QueryRequest}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public QueryRequest build() {
_checkSingleUse();
return new QueryRequest(this);
}
}
/**
* @return New {@link Builder} initialized with field values of this instance
*/
public Builder rebuild() {
return new Builder(this);
}
// ---------------------------------------------------------------------------------------------
/**
* Json deserializer for {@link QueryRequest}
*/
public static final JsonpDeserializer<QueryRequest> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
QueryRequest::setupQueryRequestDeserializer);
protected static void setupQueryRequestDeserializer(ObjectDeserializer<QueryRequest.Builder> op) {
op.add(Builder::columnar, JsonpDeserializer.booleanDeserializer(), "columnar");
op.add(Builder::filter, Query._DESERIALIZER, "filter");
op.add(Builder::includeCcsMetadata, JsonpDeserializer.booleanDeserializer(), "include_ccs_metadata");
op.add(Builder::includeExecutionMetadata, JsonpDeserializer.booleanDeserializer(),
"include_execution_metadata");
op.add(Builder::locale, JsonpDeserializer.stringDeserializer(), "locale");
op.add(Builder::params, JsonpDeserializer.arrayDeserializer(FieldValue._DESERIALIZER), "params");
op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile");
op.add(Builder::projectRouting, JsonpDeserializer.stringDeserializer(), "project_routing");
op.add(Builder::query, JsonpDeserializer.stringDeserializer(), "query");
op.add(Builder::tables, JsonpDeserializer
.stringMapDeserializer(JsonpDeserializer.stringMapDeserializer(TableValues._DESERIALIZER)), "tables");
}
// ---------------------------------------------------------------------------------------------
/**
* Endpoint "{@code esql.query}".
*/
public static final Endpoint<QueryRequest, BinaryResponse, ErrorResponse> _ENDPOINT = new BinaryEndpoint<>(
"es/esql.query",
// Request method
request -> {
return "POST";
},
// Request path
request -> {
return "/_query";
},
// Path parameters
request -> {
return Collections.emptyMap();
},
// Request parameters
request -> {
Map<String, String> params = new HashMap<>();
if (request.delimiter != null) {
params.put("delimiter", request.delimiter);
}
if (request.format != null) {
params.put("format", request.format.jsonValue());
}
if (request.allowPartialResults != null) {
params.put("allow_partial_results", String.valueOf(request.allowPartialResults));
}
if (request.dropNullColumns != null) {
params.put("drop_null_columns", String.valueOf(request.dropNullColumns));
}
return params;
}, SimpleEndpoint.emptyMap(), true, null);
}