Skip to content

Search endpoint fixes #4420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion specification/_types/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ErrorCause
/**
* A human-readable explanation of the error, in English.
*/
reason?: string
reason?: string | null
/**
* The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
*/
Expand Down
53 changes: 50 additions & 3 deletions specification/_types/Retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/

import { QueryVector, QueryVectorBuilder, RescoreVector } from '@_types/Knn'
import { float, integer } from '@_types/Numeric'
import { Sort, SortResults } from '@_types/sort'
import { FieldCollapse } from '@global/search/_types/FieldCollapse'
import { Rescore } from '@global/search/_types/rescoring'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
import { Id } from './common'
import { Id, IndexName } from './common'
import { QueryContainer } from './query_dsl/abstractions'

/**
Expand All @@ -39,13 +39,60 @@ export class RetrieverContainer {
text_similarity_reranker?: TextSimilarityReranker
/** A retriever that replaces the functionality of a rule query. */
rule?: RuleRetriever
/** A retriever that re-scores only the results produced by its child retriever. */
rescorer?: RescorerRetriever
/** A retriever that supports the combination of different retrievers through a weighted linear combination. */
linear?: LinearRetriever
/**
* A pinned retriever applies pinned documents to the underlying retriever.
* This retriever will rewrite to a PinnedQueryBuilder.
*/
pinned?: PinnedRetriever
}

export class RetrieverBase {
/** Query to filter the documents that can match. */
filter?: QueryContainer | QueryContainer[]
/** Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. */
min_score?: float
/** Retriever name. */
_name?: string
}

export class RescorerRetriever extends RetrieverBase {
/** Inner retriever. */
retriever: RetrieverContainer
rescore: Rescore | Rescore[]
}

export class LinearRetriever extends RetrieverBase {
/** Inner retrievers. */
retrievers?: InnerRetriever[]
rank_window_size: integer
}

export class PinnedRetriever extends RetrieverBase {
/** Inner retriever. */
retriever: RetrieverContainer
ids?: string[]
docs?: SpecifiedDocument[]
rank_window_size: integer
}

export class InnerRetriever {
retriever: RetrieverContainer
weight: float
normalizer: ScoreNormalizer
}

export enum ScoreNormalizer {
none,
minmax
Copy link

@ioanatia ioanatia Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I ask to please add l2_norm here? 🥺
it was just merged this week cc @mridula-s109

EDIT: we should only add this for 9.1/8.19

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ioanatia , we have to add the l2_norm in a separate PR since this one should as well be in 8.18.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for noticing this! I'll add this in another PR since l2_norm will only be available in 8.19 and 9.1

}

export class SpecifiedDocument {
index?: IndexName
id: Id
}

export class StandardRetriever extends RetrieverBase {
Expand Down Expand Up @@ -105,7 +152,7 @@ export class TextSimilarityReranker extends RetrieverBase {

export class RuleRetriever extends RetrieverBase {
/** The ruleset IDs containing the rules this retriever is evaluating against. */
ruleset_ids: Id[]
ruleset_ids: Id | Id[]
/** The match criteria that will determine if a rule in the provided rulesets should be applied. */
match_criteria: UserDefinedValue
/** The retriever whose results rules should be applied to. */
Expand Down
51 changes: 51 additions & 0 deletions specification/_types/query_dsl/fulltext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export class IntervalsContainer {
* Matches terms that start with a specified set of characters.
*/
prefix?: IntervalsPrefix
range?: IntervalsRange
regexp?: IntervalsRegexp
/**
* Matches terms using a wildcard pattern.
*/
Expand Down Expand Up @@ -232,6 +234,52 @@ export class IntervalsPrefix {
use_field?: Field
}

export class IntervalsRange {
/**
* Analyzer used to analyze the `prefix`.
* @doc_id analysis
*/
analyzer?: string
/**
* Lower term, either gte or gt must be provided.
*/
gte?: string
/**
* Lower term, either gte or gt must be provided.
*/
gt?: string
/**
* Upper term, either lte or lt must be provided.
*/
lte?: string
/**
* Upper term, either lte or lt must be provided.
*/
lt?: string
/**
* If specified, match intervals from this field rather than the top-level field.
* The `prefix` is normalized using the search analyzer from this field, unless `analyzer` is specified separately.
*/
use_field?: Field
}

export class IntervalsRegexp {
/**
* Analyzer used to analyze the `prefix`.
* @doc_id analysis
*/
analyzer?: string
/**
* Regex pattern.
*/
pattern: string
/**
* If specified, match intervals from this field rather than the top-level field.
* The `prefix` is normalized using the search analyzer from this field, unless `analyzer` is specified separately.
*/
use_field?: Field
}

/**
* @variants container
* @ext_doc_id query-dsl-intervals-query
Expand Down Expand Up @@ -259,6 +307,9 @@ export class IntervalsQuery extends QueryBase {
* Matches terms that start with a specified set of characters.
*/
prefix?: IntervalsPrefix
range?: IntervalsRange
regexp?: IntervalsRegexp

/**
* Matches terms using a wildcard pattern.
*/
Expand Down
2 changes: 1 addition & 1 deletion specification/_types/query_dsl/geo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class GeoDistanceQuery

/** @variants container */
export class GeoGridQuery extends QueryBase {
geogrid?: GeoTile
geotile?: GeoTile
geohash?: GeoHash
geohex?: GeoHexCell
}
Expand Down
3 changes: 2 additions & 1 deletion specification/_types/query_dsl/specialized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ export class ShapeFieldQuery {
*/
export class RuleQuery extends QueryBase {
organic: QueryContainer
ruleset_ids: Id[]
ruleset_ids?: Id | Id[]
ruleset_id?: string
match_criteria: UserDefinedValue
}