Skip to content

Commit 3aca7e9

Browse files
l-trottapquentin
authored andcommitted
Search endpoint fixes (#4420)
* search endpoint fixes * revert breaking changes * added linear and pinned retriever * prettier? * Run prettier * use alias types * pretty * pretty! --------- Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co> (cherry picked from commit 6e14823)
1 parent 1449da5 commit 3aca7e9

File tree

5 files changed

+105
-6
lines changed

5 files changed

+105
-6
lines changed

specification/_types/Errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ErrorCause
3838
/**
3939
* A human-readable explanation of the error, in English.
4040
*/
41-
reason?: string
41+
reason?: string | null
4242
/**
4343
* The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
4444
*/

specification/_types/Retriever.ts

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
import { QueryVector, QueryVectorBuilder, RescoreVector } from '@_types/Knn'
2120
import { float, integer } from '@_types/Numeric'
2221
import { Sort, SortResults } from '@_types/sort'
2322
import { FieldCollapse } from '@global/search/_types/FieldCollapse'
23+
import { Rescore } from '@global/search/_types/rescoring'
2424
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
25-
import { Id } from './common'
25+
import { Id, IndexName } from './common'
2626
import { QueryContainer } from './query_dsl/abstractions'
2727

2828
/**
@@ -39,13 +39,60 @@ export class RetrieverContainer {
3939
text_similarity_reranker?: TextSimilarityReranker
4040
/** A retriever that replaces the functionality of a rule query. */
4141
rule?: RuleRetriever
42+
/** A retriever that re-scores only the results produced by its child retriever. */
43+
rescorer?: RescorerRetriever
44+
/** A retriever that supports the combination of different retrievers through a weighted linear combination. */
45+
linear?: LinearRetriever
46+
/**
47+
* A pinned retriever applies pinned documents to the underlying retriever.
48+
* This retriever will rewrite to a PinnedQueryBuilder.
49+
*/
50+
pinned?: PinnedRetriever
4251
}
4352

4453
export class RetrieverBase {
4554
/** Query to filter the documents that can match. */
4655
filter?: QueryContainer | QueryContainer[]
4756
/** Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. */
4857
min_score?: float
58+
/** Retriever name. */
59+
_name?: string
60+
}
61+
62+
export class RescorerRetriever extends RetrieverBase {
63+
/** Inner retriever. */
64+
retriever: RetrieverContainer
65+
rescore: Rescore | Rescore[]
66+
}
67+
68+
export class LinearRetriever extends RetrieverBase {
69+
/** Inner retrievers. */
70+
retrievers?: InnerRetriever[]
71+
rank_window_size: integer
72+
}
73+
74+
export class PinnedRetriever extends RetrieverBase {
75+
/** Inner retriever. */
76+
retriever: RetrieverContainer
77+
ids?: string[]
78+
docs?: SpecifiedDocument[]
79+
rank_window_size: integer
80+
}
81+
82+
export class InnerRetriever {
83+
retriever: RetrieverContainer
84+
weight: float
85+
normalizer: ScoreNormalizer
86+
}
87+
88+
export enum ScoreNormalizer {
89+
none,
90+
minmax
91+
}
92+
93+
export class SpecifiedDocument {
94+
index?: IndexName
95+
id: Id
4996
}
5097

5198
export class StandardRetriever extends RetrieverBase {
@@ -105,7 +152,7 @@ export class TextSimilarityReranker extends RetrieverBase {
105152

106153
export class RuleRetriever extends RetrieverBase {
107154
/** The ruleset IDs containing the rules this retriever is evaluating against. */
108-
ruleset_ids: Id[]
155+
ruleset_ids: Id | Id[]
109156
/** The match criteria that will determine if a rule in the provided rulesets should be applied. */
110157
match_criteria: UserDefinedValue
111158
/** The retriever whose results rules should be applied to. */

specification/_types/query_dsl/fulltext.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export class IntervalsContainer {
103103
* Matches terms that start with a specified set of characters.
104104
*/
105105
prefix?: IntervalsPrefix
106+
range?: IntervalsRange
107+
regexp?: IntervalsRegexp
106108
/**
107109
* Matches terms using a wildcard pattern.
108110
*/
@@ -232,6 +234,52 @@ export class IntervalsPrefix {
232234
use_field?: Field
233235
}
234236

237+
export class IntervalsRange {
238+
/**
239+
* Analyzer used to analyze the `prefix`.
240+
* @doc_id analysis
241+
*/
242+
analyzer?: string
243+
/**
244+
* Lower term, either gte or gt must be provided.
245+
*/
246+
gte?: string
247+
/**
248+
* Lower term, either gte or gt must be provided.
249+
*/
250+
gt?: string
251+
/**
252+
* Upper term, either lte or lt must be provided.
253+
*/
254+
lte?: string
255+
/**
256+
* Upper term, either lte or lt must be provided.
257+
*/
258+
lt?: string
259+
/**
260+
* If specified, match intervals from this field rather than the top-level field.
261+
* The `prefix` is normalized using the search analyzer from this field, unless `analyzer` is specified separately.
262+
*/
263+
use_field?: Field
264+
}
265+
266+
export class IntervalsRegexp {
267+
/**
268+
* Analyzer used to analyze the `prefix`.
269+
* @doc_id analysis
270+
*/
271+
analyzer?: string
272+
/**
273+
* Regex pattern.
274+
*/
275+
pattern: string
276+
/**
277+
* If specified, match intervals from this field rather than the top-level field.
278+
* The `prefix` is normalized using the search analyzer from this field, unless `analyzer` is specified separately.
279+
*/
280+
use_field?: Field
281+
}
282+
235283
/**
236284
* @variants container
237285
* @ext_doc_id query-dsl-intervals-query
@@ -259,6 +307,9 @@ export class IntervalsQuery extends QueryBase {
259307
* Matches terms that start with a specified set of characters.
260308
*/
261309
prefix?: IntervalsPrefix
310+
range?: IntervalsRange
311+
regexp?: IntervalsRegexp
312+
262313
/**
263314
* Matches terms using a wildcard pattern.
264315
*/

specification/_types/query_dsl/geo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class GeoDistanceQuery
9797

9898
/** @variants container */
9999
export class GeoGridQuery extends QueryBase {
100-
geogrid?: GeoTile
100+
geotile?: GeoTile
101101
geohash?: GeoHash
102102
geohex?: GeoHexCell
103103
}

specification/_types/query_dsl/specialized.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ export class ShapeFieldQuery {
400400
*/
401401
export class RuleQuery extends QueryBase {
402402
organic: QueryContainer
403-
ruleset_ids: Id[]
403+
ruleset_ids?: Id | Id[]
404+
ruleset_id?: string
404405
match_criteria: UserDefinedValue
405406
}

0 commit comments

Comments
 (0)