Skip to content

Commit 8e5bcad

Browse files
committed
search body refactor + object script
1 parent f0b3dca commit 8e5bcad

File tree

10 files changed

+4538
-4137
lines changed

10 files changed

+4538
-4137
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 333 additions & 303 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/openapi/elasticsearch-serverless-openapi.json

Lines changed: 431 additions & 404 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema-serverless.json

Lines changed: 985 additions & 822 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 2488 additions & 2382 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/validation-errors.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@
4444
],
4545
"response": []
4646
},
47+
"fleet.msearch": {
48+
"request": [
49+
"interface definition _types:RankContainer - Property rrf is a single-variant and must be required"
50+
],
51+
"response": []
52+
},
4753
"get_source": {
4854
"request": [
4955
"Request: query parameter 'stored_fields' does not exist in the json spec"
@@ -87,12 +93,6 @@
8793
],
8894
"response": []
8995
},
90-
"search": {
91-
"request": [
92-
"interface definition _types:RankContainer - Property rrf is a single-variant and must be required"
93-
],
94-
"response": []
95-
},
9696
"search_mvt": {
9797
"request": [
9898
"Request: query parameter 'grid_agg' does not exist in the json spec",

output/typescript/types.ts

Lines changed: 42 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_global/msearch/types.ts

Lines changed: 4 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,15 @@
1818
*/
1919

2020
import { ResponseBody as SearchResponse } from '@global/search/SearchResponse'
21-
import { FieldCollapse } from '@global/search/_types/FieldCollapse'
22-
import { Highlight } from '@global/search/_types/highlighting'
23-
import { TrackHits } from '@global/search/_types/hits'
24-
import { PointInTimeReference } from '@global/search/_types/PointInTimeReference'
25-
import { Rescore } from '@global/search/_types/rescoring'
26-
import { SourceConfig } from '@global/search/_types/SourceFilter'
27-
import { Suggester } from '@global/search/_types/suggester'
28-
import { Dictionary, SingleKeyDictionary } from '@spec_utils/Dictionary'
29-
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
30-
import { AggregationContainer } from '@_types/aggregations/AggregationContainer'
21+
import { SearchRequestBody } from '@global/search/_types/SearchRequestBody'
3122
import { ErrorResponseBase } from '@_types/Base'
32-
import {
33-
ExpandWildcards,
34-
Fields,
35-
IndexName,
36-
Indices,
37-
Routing,
38-
SearchType
39-
} from '@_types/common'
40-
import { KnnSearch } from '@_types/Knn'
41-
import { RuntimeFields } from '@_types/mapping/RuntimeFields'
42-
import { double, integer, long } from '@_types/Numeric'
43-
import { FieldAndFormat, QueryContainer } from '@_types/query_dsl/abstractions'
44-
import { ScriptField } from '@_types/Scripting'
45-
import { Sort, SortResults } from '@_types/sort'
23+
import { ExpandWildcards, Indices, Routing, SearchType } from '@_types/common'
24+
import { integer, long } from '@_types/Numeric'
4625

4726
/**
4827
* @codegen_names header, body
4928
*/
50-
export type RequestItem = MultisearchHeader | MultisearchBody
29+
export type RequestItem = MultisearchHeader | SearchRequestBody
5130

5231
/**
5332
* Contains parameters used to limit or change the subsequent search body request.
@@ -66,143 +45,6 @@ export class MultisearchHeader {
6645
ignore_throttled?: boolean
6746
}
6847

69-
// We should keep this in sync with the normal search request body.
70-
export class MultisearchBody {
71-
/**
72-
* @aliases aggs
73-
* @ext_doc_id search-aggregations
74-
*/ // ES uses "aggregations" in serialization
75-
aggregations?: Dictionary<string, AggregationContainer>
76-
collapse?: FieldCollapse
77-
/**
78-
* Defines the search definition using the Query DSL.
79-
*/
80-
query?: QueryContainer
81-
/**
82-
* If true, returns detailed information about score computation as part of a hit.
83-
* @server_default false
84-
*/
85-
explain?: boolean
86-
/**
87-
* Configuration of search extensions defined by Elasticsearch plugins.
88-
*/
89-
ext?: Dictionary<string, UserDefinedValue>
90-
/**
91-
* List of stored fields to return as part of a hit. If no fields are specified,
92-
* no stored fields are included in the response. If this field is specified, the _source
93-
* parameter defaults to false. You can pass _source: true to return both source fields
94-
* and stored fields in the search response.
95-
*/
96-
stored_fields?: Fields
97-
/**
98-
* Array of wildcard (*) patterns. The request returns doc values for field
99-
* names matching these patterns in the hits.fields property of the response.
100-
*/
101-
docvalue_fields?: FieldAndFormat[]
102-
/**
103-
* Defines the approximate kNN search to run.
104-
* @availability stack since=8.4.0
105-
* @availability serverless
106-
*/
107-
knn?: KnnSearch | KnnSearch[]
108-
/**
109-
* Starting document offset. By default, you cannot page through more than 10,000
110-
* hits using the from and size parameters. To page through more hits, use the
111-
* search_after parameter.
112-
* @server_default 0
113-
*/
114-
from?: integer
115-
highlight?: Highlight
116-
/**
117-
* Boosts the _score of documents from specified indices.
118-
*/
119-
indices_boost?: Array<SingleKeyDictionary<IndexName, double>>
120-
/**
121-
* Minimum _score for matching documents. Documents with a lower _score are
122-
* not included in the search results.
123-
*/
124-
min_score?: double
125-
post_filter?: QueryContainer
126-
profile?: boolean
127-
rescore?: Rescore | Rescore[]
128-
/**
129-
* Retrieve a script evaluation (based on different fields) for each hit.
130-
*/
131-
script_fields?: Dictionary<string, ScriptField>
132-
search_after?: SortResults
133-
/**
134-
* The number of hits to return. By default, you cannot page through more
135-
* than 10,000 hits using the from and size parameters. To page through more
136-
* hits, use the search_after parameter.
137-
* @server_default 10
138-
*/
139-
size?: integer
140-
/** @doc_id sort-search-results */
141-
sort?: Sort
142-
/**
143-
* Indicates which source fields are returned for matching documents. These
144-
* fields are returned in the hits._source property of the search response.
145-
*/
146-
_source?: SourceConfig
147-
/**
148-
* Array of wildcard (*) patterns. The request returns values for field names
149-
* matching these patterns in the hits.fields property of the response.
150-
*/
151-
fields?: Array<FieldAndFormat>
152-
/**
153-
* Maximum number of documents to collect for each shard. If a query reaches this
154-
* limit, Elasticsearch terminates the query early. Elasticsearch collects documents
155-
* before sorting. Defaults to 0, which does not terminate query execution early.
156-
* @server_default 0
157-
*/
158-
terminate_after?: long
159-
/**
160-
* Stats groups to associate with the search. Each group maintains a statistics
161-
* aggregation for its associated searches. You can retrieve these stats using
162-
* the indices stats API.
163-
*/
164-
stats?: string[]
165-
/**
166-
* Specifies the period of time to wait for a response from each shard. If no response
167-
* is received before the timeout expires, the request fails and returns an error.
168-
* Defaults to no timeout.
169-
*/
170-
timeout?: string
171-
/**
172-
* If true, calculate and return document scores, even if the scores are not used for sorting.
173-
* @server_default false
174-
*/
175-
track_scores?: boolean
176-
/**
177-
* Number of hits matching the query to count accurately. If true, the exact
178-
* number of hits is returned at the cost of some performance. If false, the
179-
* response does not include the total number of hits matching the query.
180-
* Defaults to 10,000 hits.
181-
*/
182-
track_total_hits?: TrackHits
183-
/**
184-
* If true, returns document version as part of a hit.
185-
* @server_default false
186-
*/
187-
version?: boolean
188-
/**
189-
* Defines one or more runtime fields in the search request. These fields take
190-
* precedence over mapped fields with the same name.
191-
*/
192-
runtime_mappings?: RuntimeFields
193-
/**
194-
* If true, returns sequence number and primary term of the last modification
195-
* of each hit. See Optimistic concurrency control.
196-
*/
197-
seq_no_primary_term?: boolean
198-
/**
199-
* Limits the search to a point in time (PIT). If you provide a PIT, you
200-
* cannot specify an <index> in the request path.
201-
*/
202-
pit?: PointInTimeReference
203-
suggest?: Suggester
204-
}
205-
20648
export class MultiSearchResult<TDocument> {
20749
took: long
20850
responses: Array<ResponseItem<TDocument>>

specification/_global/search/SearchRequest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
* under the License.
1818
*/
1919

20+
import { FieldCollapse } from '@global/search/_types/FieldCollapse'
21+
import { Highlight } from '@global/search/_types/highlighting'
2022
import { TrackHits } from '@global/search/_types/hits'
23+
import { PointInTimeReference } from '@global/search/_types/PointInTimeReference'
24+
import { Rescore } from '@global/search/_types/rescoring'
25+
import { Suggester } from '@global/search/_types/suggester'
2126
import { Dictionary, SingleKeyDictionary } from '@spec_utils/Dictionary'
2227
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
2328
import { AggregationContainer } from '@_types/aggregations/AggregationContainer'
@@ -43,12 +48,7 @@ import { ScriptField } from '@_types/Scripting'
4348
import { SlicedScroll } from '@_types/SlicedScroll'
4449
import { Sort, SortResults } from '@_types/sort'
4550
import { Duration } from '@_types/Time'
46-
import { FieldCollapse } from './_types/FieldCollapse'
47-
import { Highlight } from './_types/highlighting'
48-
import { PointInTimeReference } from './_types/PointInTimeReference'
49-
import { Rescore } from './_types/rescoring'
5051
import { SourceConfig, SourceConfigParam } from './_types/SourceFilter'
51-
import { Suggester } from './_types/suggester'
5252

5353
/**
5454
* Run a search.
@@ -383,7 +383,7 @@ export interface Request extends RequestBase {
383383
*/
384384
force_synthetic_source?: boolean
385385
}
386-
// We should keep this in sync with the multi search request body.
386+
// Keep this in sync with global/search/_types/SearchRequestBody.ts
387387
body: {
388388
/**
389389
* Defines the aggregations that are run as part of the search request.

0 commit comments

Comments
 (0)