From 7ffc441919735f1574965c7ba295be4abc03d029 Mon Sep 17 00:00:00 2001 From: Sylvain Wallez Date: Thu, 14 Mar 2024 11:47:15 +0100 Subject: [PATCH] Rewrite similarity definition (#2454) --- .../elasticsearch-serverless-openapi.json | 127 ++++--- output/schema/schema.json | 320 ++++++++++-------- output/typescript/types.ts | 37 +- specification/indices/_types/IndexSettings.ts | 46 +-- 4 files changed, 285 insertions(+), 245 deletions(-) diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index e791830577..32f558fe22 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -41879,7 +41879,11 @@ "$ref": "#/components/schemas/indices._types:Queries" }, "similarity": { - "$ref": "#/components/schemas/indices._types:SettingsSimilarity" + "description": "Configure custom similarity settings to customize how search results are scored.", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/indices._types:SettingsSimilarity" + } }, "mapping": { "$ref": "#/components/schemas/indices._types:MappingLimitSettings" @@ -44923,36 +44927,45 @@ ] }, "indices._types:SettingsSimilarity": { - "type": "object", - "properties": { - "bm25": { + "discriminator": { + "propertyName": "type" + }, + "oneOf": [ + { "$ref": "#/components/schemas/indices._types:SettingsSimilarityBm25" }, - "dfi": { + { + "$ref": "#/components/schemas/indices._types:SettingsSimilarityBoolean" + }, + { "$ref": "#/components/schemas/indices._types:SettingsSimilarityDfi" }, - "dfr": { + { "$ref": "#/components/schemas/indices._types:SettingsSimilarityDfr" }, - "ib": { + { "$ref": "#/components/schemas/indices._types:SettingsSimilarityIb" }, - "lmd": { + { "$ref": "#/components/schemas/indices._types:SettingsSimilarityLmd" }, - "lmj": { + { "$ref": "#/components/schemas/indices._types:SettingsSimilarityLmj" }, - "scripted_tfidf": { - "$ref": "#/components/schemas/indices._types:SettingsSimilarityScriptedTfidf" + { + "$ref": "#/components/schemas/indices._types:SettingsSimilarityScripted" } - }, - "minProperties": 1, - "maxProperties": 1 + ] }, "indices._types:SettingsSimilarityBm25": { "type": "object", "properties": { + "type": { + "type": "string", + "enum": [ + "BM25" + ] + }, "b": { "type": "number" }, @@ -44961,37 +44974,42 @@ }, "k1": { "type": "number" - }, + } + }, + "required": [ + "type" + ] + }, + "indices._types:SettingsSimilarityBoolean": { + "type": "object", + "properties": { "type": { "type": "string", "enum": [ - "BM25" + "boolean" ] } }, "required": [ - "b", - "discount_overlaps", - "k1", "type" ] }, "indices._types:SettingsSimilarityDfi": { "type": "object", "properties": { - "independence_measure": { - "$ref": "#/components/schemas/_types:DFIIndependenceMeasure" - }, "type": { "type": "string", "enum": [ "DFI" ] + }, + "independence_measure": { + "$ref": "#/components/schemas/_types:DFIIndependenceMeasure" } }, "required": [ - "independence_measure", - "type" + "type", + "independence_measure" ] }, "_types:DFIIndependenceMeasure": { @@ -45005,6 +45023,12 @@ "indices._types:SettingsSimilarityDfr": { "type": "object", "properties": { + "type": { + "type": "string", + "enum": [ + "DFR" + ] + }, "after_effect": { "$ref": "#/components/schemas/_types:DFRAfterEffect" }, @@ -45013,19 +45037,13 @@ }, "normalization": { "$ref": "#/components/schemas/_types:Normalization" - }, - "type": { - "type": "string", - "enum": [ - "DFR" - ] } }, "required": [ + "type", "after_effect", "basic_model", - "normalization", - "type" + "normalization" ] }, "_types:DFRAfterEffect": { @@ -45061,6 +45079,12 @@ "indices._types:SettingsSimilarityIb": { "type": "object", "properties": { + "type": { + "type": "string", + "enum": [ + "IB" + ] + }, "distribution": { "$ref": "#/components/schemas/_types:IBDistribution" }, @@ -45069,19 +45093,13 @@ }, "normalization": { "$ref": "#/components/schemas/_types:Normalization" - }, - "type": { - "type": "string", - "enum": [ - "IB" - ] } }, "required": [ + "type", "distribution", "lambda", - "normalization", - "type" + "normalization" ] }, "_types:IBDistribution": { @@ -45101,55 +45119,56 @@ "indices._types:SettingsSimilarityLmd": { "type": "object", "properties": { - "mu": { - "type": "number" - }, "type": { "type": "string", "enum": [ "LMDirichlet" ] + }, + "mu": { + "type": "number" } }, "required": [ - "mu", "type" ] }, "indices._types:SettingsSimilarityLmj": { "type": "object", "properties": { - "lambda": { - "type": "number" - }, "type": { "type": "string", "enum": [ "LMJelinekMercer" ] + }, + "lambda": { + "type": "number" } }, "required": [ - "lambda", "type" ] }, - "indices._types:SettingsSimilarityScriptedTfidf": { + "indices._types:SettingsSimilarityScripted": { "type": "object", "properties": { - "script": { - "$ref": "#/components/schemas/_types:Script" - }, "type": { "type": "string", "enum": [ "scripted" ] + }, + "script": { + "$ref": "#/components/schemas/_types:Script" + }, + "weight_script": { + "$ref": "#/components/schemas/_types:Script" } }, "required": [ - "script", - "type" + "type", + "script" ] }, "indices._types:MappingLimitSettings": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 27c7764fbc..d203c12586 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -111010,7 +111010,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L401-L403" + "specLocation": "indices/_types/IndexSettings.ts#L405-L407" }, { "kind": "interface", @@ -111680,7 +111680,7 @@ "name": "IndexCheckOnStartup", "namespace": "indices._types" }, - "specLocation": "indices/_types/IndexSettings.ts#L256-L263" + "specLocation": "indices/_types/IndexSettings.ts#L260-L267" }, { "kind": "interface", @@ -112126,7 +112126,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L248-L254" + "specLocation": "indices/_types/IndexSettings.ts#L252-L258" }, { "attachedBehaviors": [ @@ -112862,10 +112862,21 @@ "name": "similarity", "required": false, "type": { - "kind": "instance_of", - "type": { - "name": "SettingsSimilarity", - "namespace": "indices._types" + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + }, + "kind": "dictionary_of", + "singleKey": false, + "value": { + "kind": "instance_of", + "type": { + "name": "SettingsSimilarity", + "namespace": "indices._types" + } } } }, @@ -113037,7 +113048,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L313-L319" + "specLocation": "indices/_types/IndexSettings.ts#L317-L323" }, { "kind": "interface", @@ -113130,7 +113141,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L270-L303" + "specLocation": "indices/_types/IndexSettings.ts#L274-L307" }, { "kind": "interface", @@ -113152,7 +113163,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L305-L311" + "specLocation": "indices/_types/IndexSettings.ts#L309-L315" }, { "kind": "interface", @@ -113184,7 +113195,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L321-L324" + "specLocation": "indices/_types/IndexSettings.ts#L325-L328" }, { "kind": "interface", @@ -113541,7 +113552,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L265-L268" + "specLocation": "indices/_types/IndexSettings.ts#L269-L272" }, { "kind": "interface", @@ -113562,7 +113573,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L537-L539" + "specLocation": "indices/_types/IndexSettings.ts#L541-L543" }, { "kind": "interface", @@ -113584,7 +113595,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L541-L548" + "specLocation": "indices/_types/IndexSettings.ts#L545-L552" }, { "kind": "interface", @@ -113638,7 +113649,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L550-L555" + "specLocation": "indices/_types/IndexSettings.ts#L554-L559" }, { "kind": "interface", @@ -113662,7 +113673,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L557-L564" + "specLocation": "indices/_types/IndexSettings.ts#L561-L568" }, { "kind": "enum", @@ -113785,7 +113796,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L405-L418" + "specLocation": "indices/_types/IndexSettings.ts#L409-L422" }, { "kind": "interface", @@ -113808,7 +113819,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L430-L437" + "specLocation": "indices/_types/IndexSettings.ts#L434-L441" }, { "kind": "interface", @@ -113830,7 +113841,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L467-L473" + "specLocation": "indices/_types/IndexSettings.ts#L471-L477" }, { "kind": "interface", @@ -113852,7 +113863,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L458-L465" + "specLocation": "indices/_types/IndexSettings.ts#L462-L469" }, { "kind": "interface", @@ -113875,7 +113886,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L439-L447" + "specLocation": "indices/_types/IndexSettings.ts#L443-L451" }, { "kind": "interface", @@ -113898,7 +113909,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L449-L456" + "specLocation": "indices/_types/IndexSettings.ts#L453-L460" }, { "kind": "interface", @@ -113921,7 +113932,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L420-L428" + "specLocation": "indices/_types/IndexSettings.ts#L424-L432" }, { "kind": "interface", @@ -113942,7 +113953,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L326-L328" + "specLocation": "indices/_types/IndexSettings.ts#L330-L332" }, { "kind": "interface", @@ -113992,7 +114003,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L330-L333" + "specLocation": "indices/_types/IndexSettings.ts#L334-L337" }, { "kind": "interface", @@ -114050,7 +114061,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L397-L399" + "specLocation": "indices/_types/IndexSettings.ts#L401-L403" }, { "kind": "interface", @@ -114093,7 +114104,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L239-L242" + "specLocation": "indices/_types/IndexSettings.ts#L243-L246" }, { "kind": "enum", @@ -114186,7 +114197,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L229-L232" + "specLocation": "indices/_types/IndexSettings.ts#L233-L236" }, { "kind": "interface", @@ -114208,7 +114219,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L224-L227" + "specLocation": "indices/_types/IndexSettings.ts#L228-L231" }, { "kind": "interface", @@ -114238,7 +114249,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L244-L246" + "specLocation": "indices/_types/IndexSettings.ts#L248-L250" }, { "kind": "interface", @@ -114270,97 +114281,79 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L234-L237" + "specLocation": "indices/_types/IndexSettings.ts#L238-L241" }, { - "kind": "interface", + "kind": "type_alias", "name": { "name": "SettingsSimilarity", "namespace": "indices._types" }, - "properties": [ - { - "name": "bm25", - "required": false, - "type": { + "specLocation": "indices/_types/IndexSettings.ts#L169-L180", + "type": { + "items": [ + { "kind": "instance_of", "type": { "name": "SettingsSimilarityBm25", "namespace": "indices._types" } - } - }, - { - "name": "dfi", - "required": false, - "type": { + }, + { + "kind": "instance_of", + "type": { + "name": "SettingsSimilarityBoolean", + "namespace": "indices._types" + } + }, + { "kind": "instance_of", "type": { "name": "SettingsSimilarityDfi", "namespace": "indices._types" } - } - }, - { - "name": "dfr", - "required": false, - "type": { + }, + { "kind": "instance_of", "type": { "name": "SettingsSimilarityDfr", "namespace": "indices._types" } - } - }, - { - "name": "ib", - "required": false, - "type": { + }, + { "kind": "instance_of", "type": { "name": "SettingsSimilarityIb", "namespace": "indices._types" } - } - }, - { - "name": "lmd", - "required": false, - "type": { + }, + { "kind": "instance_of", "type": { "name": "SettingsSimilarityLmd", "namespace": "indices._types" } - } - }, - { - "name": "lmj", - "required": false, - "type": { + }, + { "kind": "instance_of", "type": { "name": "SettingsSimilarityLmj", "namespace": "indices._types" } - } - }, - { - "name": "scripted_tfidf", - "required": false, - "type": { + }, + { "kind": "instance_of", "type": { - "name": "SettingsSimilarityScriptedTfidf", + "name": "SettingsSimilarityScripted", "namespace": "indices._types" } } - } - ], - "specLocation": "indices/_types/IndexSettings.ts#L169-L181", + ], + "kind": "union_of" + }, "variants": { - "kind": "container", - "nonExhaustive": true + "kind": "internal_tag", + "tag": "type" } }, { @@ -114371,8 +114364,16 @@ }, "properties": [ { - "name": "b", + "name": "type", "required": true, + "type": { + "kind": "literal_value", + "value": "BM25" + } + }, + { + "name": "b", + "required": false, "type": { "kind": "instance_of", "type": { @@ -114383,7 +114384,7 @@ }, { "name": "discount_overlaps", - "required": true, + "required": false, "type": { "kind": "instance_of", "type": { @@ -114394,7 +114395,7 @@ }, { "name": "k1", - "required": true, + "required": false, "type": { "kind": "instance_of", "type": { @@ -114402,17 +114403,27 @@ "namespace": "_types" } } - }, + } + ], + "specLocation": "indices/_types/IndexSettings.ts#L186-L191" + }, + { + "kind": "interface", + "name": { + "name": "SettingsSimilarityBoolean", + "namespace": "indices._types" + }, + "properties": [ { "name": "type", "required": true, "type": { "kind": "literal_value", - "value": "BM25" + "value": "boolean" } } ], - "specLocation": "indices/_types/IndexSettings.ts#L183-L188" + "specLocation": "indices/_types/IndexSettings.ts#L182-L184" }, { "kind": "interface", @@ -114421,6 +114432,14 @@ "namespace": "indices._types" }, "properties": [ + { + "name": "type", + "required": true, + "type": { + "kind": "literal_value", + "value": "DFI" + } + }, { "name": "independence_measure", "required": true, @@ -114431,17 +114450,9 @@ "namespace": "_types" } } - }, - { - "name": "type", - "required": true, - "type": { - "kind": "literal_value", - "value": "DFI" - } } ], - "specLocation": "indices/_types/IndexSettings.ts#L190-L193" + "specLocation": "indices/_types/IndexSettings.ts#L193-L196" }, { "kind": "interface", @@ -114450,6 +114461,14 @@ "namespace": "indices._types" }, "properties": [ + { + "name": "type", + "required": true, + "type": { + "kind": "literal_value", + "value": "DFR" + } + }, { "name": "after_effect", "required": true, @@ -114482,17 +114501,9 @@ "namespace": "_types" } } - }, - { - "name": "type", - "required": true, - "type": { - "kind": "literal_value", - "value": "DFR" - } } ], - "specLocation": "indices/_types/IndexSettings.ts#L195-L200" + "specLocation": "indices/_types/IndexSettings.ts#L198-L203" }, { "kind": "interface", @@ -114501,6 +114512,14 @@ "namespace": "indices._types" }, "properties": [ + { + "name": "type", + "required": true, + "type": { + "kind": "literal_value", + "value": "IB" + } + }, { "name": "distribution", "required": true, @@ -114533,17 +114552,9 @@ "namespace": "_types" } } - }, - { - "name": "type", - "required": true, - "type": { - "kind": "literal_value", - "value": "IB" - } } ], - "specLocation": "indices/_types/IndexSettings.ts#L202-L207" + "specLocation": "indices/_types/IndexSettings.ts#L205-L210" }, { "kind": "interface", @@ -114553,26 +114564,26 @@ }, "properties": [ { - "name": "mu", + "name": "type", "required": true, "type": { - "kind": "instance_of", - "type": { - "name": "integer", - "namespace": "_types" - } + "kind": "literal_value", + "value": "LMDirichlet" } }, { - "name": "type", - "required": true, + "name": "mu", + "required": false, "type": { - "kind": "literal_value", - "value": "LMDirichlet" + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } } } ], - "specLocation": "indices/_types/IndexSettings.ts#L209-L212" + "specLocation": "indices/_types/IndexSettings.ts#L212-L215" }, { "kind": "interface", @@ -114582,8 +114593,16 @@ }, "properties": [ { - "name": "lambda", + "name": "type", "required": true, + "type": { + "kind": "literal_value", + "value": "LMJelinekMercer" + } + }, + { + "name": "lambda", + "required": false, "type": { "kind": "instance_of", "type": { @@ -114591,25 +114610,25 @@ "namespace": "_types" } } - }, - { - "name": "type", - "required": true, - "type": { - "kind": "literal_value", - "value": "LMJelinekMercer" - } } ], - "specLocation": "indices/_types/IndexSettings.ts#L214-L217" + "specLocation": "indices/_types/IndexSettings.ts#L217-L220" }, { "kind": "interface", "name": { - "name": "SettingsSimilarityScriptedTfidf", + "name": "SettingsSimilarityScripted", "namespace": "indices._types" }, "properties": [ + { + "name": "type", + "required": true, + "type": { + "kind": "literal_value", + "value": "scripted" + } + }, { "name": "script", "required": true, @@ -114622,15 +114641,18 @@ } }, { - "name": "type", - "required": true, + "name": "weight_script", + "required": false, "type": { - "kind": "literal_value", - "value": "scripted" + "kind": "instance_of", + "type": { + "name": "Script", + "namespace": "_types" + } } } ], - "specLocation": "indices/_types/IndexSettings.ts#L219-L222" + "specLocation": "indices/_types/IndexSettings.ts#L222-L226" }, { "kind": "interface", @@ -114684,7 +114706,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L475-L480" + "specLocation": "indices/_types/IndexSettings.ts#L479-L484" }, { "kind": "interface", @@ -114738,7 +114760,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L487-L492" + "specLocation": "indices/_types/IndexSettings.ts#L491-L496" }, { "kind": "interface", @@ -114770,7 +114792,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L482-L485" + "specLocation": "indices/_types/IndexSettings.ts#L486-L489" }, { "kind": "interface", @@ -114838,7 +114860,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L494-L503" + "specLocation": "indices/_types/IndexSettings.ts#L498-L507" }, { "isOpen": true, @@ -114868,7 +114890,7 @@ "name": "StorageType", "namespace": "indices._types" }, - "specLocation": "indices/_types/IndexSettings.ts#L505-L535" + "specLocation": "indices/_types/IndexSettings.ts#L509-L539" }, { "kind": "interface", @@ -115025,7 +115047,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L335-L357" + "specLocation": "indices/_types/IndexSettings.ts#L339-L361" }, { "kind": "enum", @@ -115049,7 +115071,7 @@ "name": "TranslogDurability", "namespace": "indices._types" }, - "specLocation": "indices/_types/IndexSettings.ts#L359-L374" + "specLocation": "indices/_types/IndexSettings.ts#L363-L378" }, { "kind": "interface", @@ -115085,7 +115107,7 @@ } } ], - "specLocation": "indices/_types/IndexSettings.ts#L376-L395" + "specLocation": "indices/_types/IndexSettings.ts#L380-L399" }, { "kind": "enum", @@ -155890,9 +155912,7 @@ }, { "availability": { - "serverless": { - "since": "8.12.0" - }, + "serverless": {}, "stack": { "since": "8.12.0" } diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 283354643c..c106d6beb2 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -9883,7 +9883,7 @@ export interface IndicesIndexSettingsKeys { settings?: IndicesIndexSettings time_series?: IndicesIndexSettingsTimeSeries queries?: IndicesQueries - similarity?: IndicesSettingsSimilarity + similarity?: Record mapping?: IndicesMappingLimitSettings 'indexing.slowlog'?: IndicesIndexingSlowlogSettings indexing_pressure?: IndicesIndexingPressure @@ -10061,55 +10061,52 @@ export interface IndicesSettingsSearch { slowlog?: IndicesSlowlogSettings } -export interface IndicesSettingsSimilarity { - bm25?: IndicesSettingsSimilarityBm25 - dfi?: IndicesSettingsSimilarityDfi - dfr?: IndicesSettingsSimilarityDfr - ib?: IndicesSettingsSimilarityIb - lmd?: IndicesSettingsSimilarityLmd - lmj?: IndicesSettingsSimilarityLmj - scripted_tfidf?: IndicesSettingsSimilarityScriptedTfidf -} +export type IndicesSettingsSimilarity = IndicesSettingsSimilarityBm25 | IndicesSettingsSimilarityBoolean | IndicesSettingsSimilarityDfi | IndicesSettingsSimilarityDfr | IndicesSettingsSimilarityIb | IndicesSettingsSimilarityLmd | IndicesSettingsSimilarityLmj | IndicesSettingsSimilarityScripted export interface IndicesSettingsSimilarityBm25 { - b: double - discount_overlaps: boolean - k1: double type: 'BM25' + b?: double + discount_overlaps?: boolean + k1?: double +} + +export interface IndicesSettingsSimilarityBoolean { + type: 'boolean' } export interface IndicesSettingsSimilarityDfi { - independence_measure: DFIIndependenceMeasure type: 'DFI' + independence_measure: DFIIndependenceMeasure } export interface IndicesSettingsSimilarityDfr { + type: 'DFR' after_effect: DFRAfterEffect basic_model: DFRBasicModel normalization: Normalization - type: 'DFR' } export interface IndicesSettingsSimilarityIb { + type: 'IB' distribution: IBDistribution lambda: IBLambda normalization: Normalization - type: 'IB' } export interface IndicesSettingsSimilarityLmd { - mu: integer type: 'LMDirichlet' + mu?: double } export interface IndicesSettingsSimilarityLmj { - lambda: double type: 'LMJelinekMercer' + lambda?: double } -export interface IndicesSettingsSimilarityScriptedTfidf { - script: Script +export interface IndicesSettingsSimilarityScripted { type: 'scripted' + script: Script + weight_script?: Script } export interface IndicesSlowlogSettings { diff --git a/specification/indices/_types/IndexSettings.ts b/specification/indices/_types/IndexSettings.ts index df538542a0..3ffce4f1f7 100644 --- a/specification/indices/_types/IndexSettings.ts +++ b/specification/indices/_types/IndexSettings.ts @@ -150,7 +150,7 @@ export class IndexSettings /** * Configure custom similarity settings to customize how search results are scored. */ - similarity?: SettingsSimilarity + similarity?: Dictionary /** * Enable or disable dynamic mapping for an index. */ @@ -167,58 +167,62 @@ export class IndexSettings } /** - * @variants container - * @non_exhaustive + * @variants internal tag='type' */ -export class SettingsSimilarity { - bm25?: SettingsSimilarityBm25 - dfi?: SettingsSimilarityDfi - dfr?: SettingsSimilarityDfr - ib?: SettingsSimilarityIb - lmd?: SettingsSimilarityLmd - lmj?: SettingsSimilarityLmj - scripted_tfidf?: SettingsSimilarityScriptedTfidf +export type SettingsSimilarity = + | SettingsSimilarityBm25 + | SettingsSimilarityBoolean + | SettingsSimilarityDfi + | SettingsSimilarityDfr + | SettingsSimilarityIb + | SettingsSimilarityLmd + | SettingsSimilarityLmj + | SettingsSimilarityScripted + +export class SettingsSimilarityBoolean { + type: 'boolean' } export class SettingsSimilarityBm25 { - b: double - discount_overlaps: boolean - k1: double type: 'BM25' + b?: double + discount_overlaps?: boolean + k1?: double } export class SettingsSimilarityDfi { - independence_measure: DFIIndependenceMeasure type: 'DFI' + independence_measure: DFIIndependenceMeasure } export class SettingsSimilarityDfr { + type: 'DFR' after_effect: DFRAfterEffect basic_model: DFRBasicModel normalization: Normalization - type: 'DFR' } export class SettingsSimilarityIb { + type: 'IB' distribution: IBDistribution lambda: IBLambda normalization: Normalization - type: 'IB' } export class SettingsSimilarityLmd { - mu: integer type: 'LMDirichlet' + mu?: double } export class SettingsSimilarityLmj { - lambda: double type: 'LMJelinekMercer' + lambda?: double } -export class SettingsSimilarityScriptedTfidf { - script: Script +export class SettingsSimilarityScripted { type: 'scripted' + script: Script + weight_script?: Script } export class SettingsHighlight {