|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import { Field, Id } from '@_types/common' |
| 21 | +import { QueryBase } from './abstractions' |
| 22 | +import { float } from '@_types/Numeric' |
| 23 | +import { Dictionary } from '@spec_utils/Dictionary' |
| 24 | +import { TokenPruningConfig } from './TokenPruningConfig' |
| 25 | + |
| 26 | +export class SparseVectorQuery extends QueryBase { |
| 27 | + /** |
| 28 | + * The name of the field that contains the token-weight pairs to be searched against. |
| 29 | + * This field must be a mapped sparse_vector field. |
| 30 | + */ |
| 31 | + field: Field |
| 32 | + |
| 33 | + /** |
| 34 | + * Dictionary of precomputed sparse vectors and their associated weights. |
| 35 | + * Only one of inference_id or query_vector may be supplied in a request. |
| 36 | + */ |
| 37 | + query_vector?: Dictionary<string, float> |
| 38 | + |
| 39 | + /** |
| 40 | + * The inference ID to use to convert the query text into token-weight pairs. |
| 41 | + * It must be the same inference ID that was used to create the tokens from the input text. |
| 42 | + * Only one of inference_id and query_vector is allowed. |
| 43 | + * If inference_id is specified, query must also be specified. |
| 44 | + * Only one of inference_id or query_vector may be supplied in a request. |
| 45 | + */ |
| 46 | + inference_id?: Id |
| 47 | + |
| 48 | + /** |
| 49 | + * The query text you want to use for search. |
| 50 | + * If inference_id is specified, query must also be specified. |
| 51 | + */ |
| 52 | + query?: String |
| 53 | + |
| 54 | + /** |
| 55 | + * Whether to perform pruning, omitting the non-significant tokens from the query to improve query performance. |
| 56 | + * If prune is true but the pruning_config is not specified, pruning will occur but default values will be used. |
| 57 | + * @default false |
| 58 | + * @availability stack since=8.15.0 stability=experimental |
| 59 | + * @availability serverless stability=experimental |
| 60 | + */ |
| 61 | + prune?: Boolean |
| 62 | + |
| 63 | + /** |
| 64 | + * Optional pruning configuration. |
| 65 | + * If enabled, this will omit non-significant tokens from the query in order to improve query performance. |
| 66 | + * This is only used if prune is set to true. |
| 67 | + * If prune is set to true but pruning_config is not specified, default values will be used. |
| 68 | + * @availability stack since=8.15.0 stability=experimental |
| 69 | + * @availability serverless stability=experimental |
| 70 | + */ |
| 71 | + pruning_config?: TokenPruningConfig |
| 72 | +} |
0 commit comments