Skip to content

Commit

Permalink
Auto-generated API code
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed May 18, 2024
1 parent 05f7078 commit 3a91064
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ A post filter has no impact on the aggregation results.
NOTE: This is a debugging tool and adds significant overhead to search execution.
** *`query` (Optional, { bool, boosting, common, combined_fields, constant_score, dis_max, distance_feature, exists, function_score, fuzzy, geo_bounding_box, geo_distance, geo_polygon, geo_shape, has_child, has_parent, ids, intervals, knn, match, match_all, match_bool_prefix, match_none, match_phrase, match_phrase_prefix, more_like_this, multi_match, nested, parent_id, percolate, pinned, prefix, query_string, range, rank_feature, regexp, rule_query, script, script_score, shape, simple_query_string, span_containing, field_masking_span, span_first, span_multi, span_near, span_not, span_or, span_term, span_within, term, terms, terms_set, text_expansion, weighted_tokens, wildcard, wrapper, type })*: Defines the search definition using the Query DSL.
** *`rescore` (Optional, { window_size, query, learning_to_rank } | { window_size, query, learning_to_rank }[])*: Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the `query` and `post_filter` phases.
** *`retriever` (Optional, { standard, knn, rrf })*: A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such as query and knn.
** *`script_fields` (Optional, Record<string, { script, ignore_failure }>)*: Retrieve a script evaluation (based on different fields) for each hit.
** *`search_after` (Optional, number | number | string | boolean | null | User-defined value[])*: Used to retrieve the next page of hits using a set of sort values from the previous page.
** *`size` (Optional, number)*: The number of hits to return.
Expand Down
2 changes: 1 addition & 1 deletion src/api/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default async function SearchApi<TDocument = unknown, TAggregations = Rec
export default async function SearchApi<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.SearchRequest | TB.SearchRequest, options?: TransportRequestOptions): Promise<T.SearchResponse<TDocument, TAggregations>>
export default async function SearchApi<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.SearchRequest | TB.SearchRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'ext', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'knn', 'rank', 'min_score', 'post_filter', 'profile', 'query', 'rescore', 'script_fields', 'search_after', 'size', 'slice', 'sort', '_source', 'fields', 'suggest', 'terminate_after', 'timeout', 'track_scores', 'version', 'seq_no_primary_term', 'stored_fields', 'pit', 'runtime_mappings', 'stats']
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'ext', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'knn', 'rank', 'min_score', 'post_filter', 'profile', 'query', 'rescore', 'retriever', 'script_fields', 'search_after', 'size', 'slice', 'sort', '_source', 'fields', 'suggest', 'terminate_after', 'timeout', 'track_scores', 'version', 'seq_no_primary_term', 'stored_fields', 'pit', 'runtime_mappings', 'stats']
const querystring: Record<string, any> = {}
// @ts-expect-error
const userBody: any = params?.body
Expand Down
45 changes: 40 additions & 5 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ export interface KnnSearchResponse<TDocument = unknown> {
export interface KnnSearchQuery {
field: Field
query_vector: QueryVector
k: long
num_candidates: long
k: integer
num_candidates: integer
}

export interface MgetMultiGetError {
Expand Down Expand Up @@ -1167,6 +1167,7 @@ export interface SearchRequest extends RequestBase {
profile?: boolean
query?: QueryDslQueryContainer
rescore?: SearchRescore | SearchRescore[]
retriever?: RetrieverContainer
script_fields?: Record<string, ScriptField>
search_after?: SortResults
size?: integer
Expand Down Expand Up @@ -2294,17 +2295,26 @@ export interface KnnQuery extends QueryDslQueryBase {
field: Field
query_vector?: QueryVector
query_vector_builder?: QueryVectorBuilder
num_candidates?: long
num_candidates?: integer
filter?: QueryDslQueryContainer | QueryDslQueryContainer[]
similarity?: float
}

export interface KnnRetriever extends RetrieverBase {
field: string
query_vector?: QueryVector
query_vector_builder?: QueryVectorBuilder
k: integer
num_candidates: integer
similarity?: float
}

export interface KnnSearch {
field: Field
query_vector?: QueryVector
query_vector_builder?: QueryVectorBuilder
k?: long
num_candidates?: long
k?: integer
num_candidates?: integer
boost?: float
filter?: QueryDslQueryContainer | QueryDslQueryContainer[]
similarity?: float
Expand Down Expand Up @@ -2443,6 +2453,12 @@ export interface QueryVectorBuilder {
text_embedding?: TextEmbedding
}

export interface RRFRetriever extends RetrieverBase {
retrievers: RetrieverContainer[]
rank_constant?: integer
rank_window_size?: integer
}

export interface RankBase {
}

Expand Down Expand Up @@ -2492,6 +2508,16 @@ export interface Retries {
search: long
}

export interface RetrieverBase {
filter?: QueryDslQueryContainer | QueryDslQueryContainer[]
}

export interface RetrieverContainer {
standard?: StandardRetriever
knn?: KnnRetriever
rrf?: RRFRetriever
}

export type Routing = string

export interface RrfRank {
Expand Down Expand Up @@ -2647,6 +2673,15 @@ export type SortOrder = 'asc' | 'desc'

export type SortResults = FieldValue[]

export interface StandardRetriever extends RetrieverBase {
query?: QueryDslQueryContainer
search_after?: SortResults
terminate_after?: integer
sort?: Sort
min_score?: float
collapse?: SearchFieldCollapse
}

export interface StoreStats {
size?: ByteSize
size_in_bytes: long
Expand Down
45 changes: 40 additions & 5 deletions src/api/typesWithBodyKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ export interface KnnSearchResponse<TDocument = unknown> {
export interface KnnSearchQuery {
field: Field
query_vector: QueryVector
k: long
num_candidates: long
k: integer
num_candidates: integer
}

export interface MgetMultiGetError {
Expand Down Expand Up @@ -1221,6 +1221,7 @@ export interface SearchRequest extends RequestBase {
profile?: boolean
query?: QueryDslQueryContainer
rescore?: SearchRescore | SearchRescore[]
retriever?: RetrieverContainer
script_fields?: Record<string, ScriptField>
search_after?: SortResults
size?: integer
Expand Down Expand Up @@ -2367,17 +2368,26 @@ export interface KnnQuery extends QueryDslQueryBase {
field: Field
query_vector?: QueryVector
query_vector_builder?: QueryVectorBuilder
num_candidates?: long
num_candidates?: integer
filter?: QueryDslQueryContainer | QueryDslQueryContainer[]
similarity?: float
}

export interface KnnRetriever extends RetrieverBase {
field: string
query_vector?: QueryVector
query_vector_builder?: QueryVectorBuilder
k: integer
num_candidates: integer
similarity?: float
}

export interface KnnSearch {
field: Field
query_vector?: QueryVector
query_vector_builder?: QueryVectorBuilder
k?: long
num_candidates?: long
k?: integer
num_candidates?: integer
boost?: float
filter?: QueryDslQueryContainer | QueryDslQueryContainer[]
similarity?: float
Expand Down Expand Up @@ -2516,6 +2526,12 @@ export interface QueryVectorBuilder {
text_embedding?: TextEmbedding
}

export interface RRFRetriever extends RetrieverBase {
retrievers: RetrieverContainer[]
rank_constant?: integer
rank_window_size?: integer
}

export interface RankBase {
}

Expand Down Expand Up @@ -2565,6 +2581,16 @@ export interface Retries {
search: long
}

export interface RetrieverBase {
filter?: QueryDslQueryContainer | QueryDslQueryContainer[]
}

export interface RetrieverContainer {
standard?: StandardRetriever
knn?: KnnRetriever
rrf?: RRFRetriever
}

export type Routing = string

export interface RrfRank {
Expand Down Expand Up @@ -2720,6 +2746,15 @@ export type SortOrder = 'asc' | 'desc'

export type SortResults = FieldValue[]

export interface StandardRetriever extends RetrieverBase {
query?: QueryDslQueryContainer
search_after?: SortResults
terminate_after?: integer
sort?: Sort
min_score?: float
collapse?: SearchFieldCollapse
}

export interface StoreStats {
size?: ByteSize
size_in_bytes: long
Expand Down

0 comments on commit 3a91064

Please sign in to comment.