Skip to content

Commit

Permalink
Merge #1640
Browse files Browse the repository at this point in the history
1640: Changes related to the next Meilisearch release (v1.8.0) r=brunoocasali a=meili-bot

Related to this issue: meilisearch/integration-guides#299

This PR:
- gathers the changes related to the next Meilisearch release (v1.8.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases).
- might eventually contain test failures until the Meilisearch v1.8.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.8.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._


Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: amit-ksh <ksamit1110@gmail.com>
Co-authored-by: Morgane Dubus <30866152+mdubus@users.noreply.github.com>
Co-authored-by: curquiza <clementine@meilisearch.com>
Co-authored-by: Morgane Dubus <morgane.d@meilisearch.com>
  • Loading branch information
6 people authored May 6, 2024
2 parents 406b689 + d4a7648 commit 6a97984
Show file tree
Hide file tree
Showing 10 changed files with 723 additions and 7 deletions.
13 changes: 12 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ update_settings_1: |-
},
faceting: {
maxValuesPerFacet: 200
}
},
searchCutoffMs: 150
})
reset_settings_1: |-
client.index('movies').resetSettings()
Expand Down Expand Up @@ -636,6 +637,12 @@ update_proximity_precision_settings_1: |-
client.index('books').updateProximityPrecision('byAttribute')
reset_proximity_precision_settings_1: |-
client.index('books').resetProximityPrecision()
get_search_cutoff_1: |-
client.index('movies').getSearchCutoffMs()
update_search_cutoff_1: |-
client.index('movies').updateSearchCutoffMs(150)
reset_search_cutoff_1: |-
client.index('movies').resetSearchCutoffMs()
search_parameter_guide_facet_stats_1: |-
client.index('movie_ratings').search('Batman', { facets: ['genres', 'rating'] })
geosearch_guide_filter_settings_1: |-
Expand Down Expand Up @@ -743,3 +750,7 @@ facet_search_3: |-
})
search_parameter_guide_show_ranking_score_details_1: |-
client.index('movies').search('dragon', { showRankingScoreDetails: true })
negative_search_1: |-
client.index('movies').search('-escape')
negative_search_2: |-
client.index('movies').search('-"escape"')
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ client.index('myIndex').resetProximityPrecision(): Promise<EnqueuedTask>

### Embedders <!-- omit in toc -->

⚠️ This feature is experimental. Activate the [`vectorStore` experimental feature to use it](https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features)
⚠️ This feature is experimental. Activate the [`vectorStore` experimental feature to use it](https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features)

#### [Get embedders](https://www.meilisearch.com/docs/reference/api/settings#get-embedders)

Expand All @@ -1003,6 +1003,26 @@ client.index('myIndex').updateEmbedders(embedders: Embedders): Promise<EnqueuedT
client.index('myIndex').resetEmbedders(): Promise<EnqueuedTask>
```

### SearchCutoffMs <!-- omit in toc -->

#### [Get SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#get-search-cutoff-ms)

```ts
client.index('myIndex').getSearchCutoffMs(): Promise<SearchCutoffMs>
```

#### [Update SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#update-search-cutoff-ms)

```ts
client.index('myIndex').updateSearchCutoffMs(searchCutoffMs: SearchCutoffMs): Promise<EnqueuedTask>
```

#### [Reset SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#reset-search-cutoff-ms)

```ts
client.index('myIndex').resetSearchCutoffMs(): Promise<EnqueuedTask>
```

### Keys <!-- omit in toc -->

#### [Get keys](https://www.meilisearch.com/docs/reference/api/keys#get-all-keys)
Expand Down
42 changes: 42 additions & 0 deletions src/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
Dictionary,
ProximityPrecision,
Embedders,
SearchCutoffMs,
} from './types'
import { removeUndefinedFromObject } from './utils'
import { HttpRequests } from './http-requests'
Expand Down Expand Up @@ -1334,6 +1335,47 @@ class Index<T extends Record<string, any> = Record<string, any>> {

return task
}

///
/// SEARCHCUTOFFMS SETTINGS
///

/**
* Get the SearchCutoffMs settings.
*
* @returns Promise containing object of SearchCutoffMs settings
*/
async getSearchCutoffMs(): Promise<SearchCutoffMs> {
const url = `indexes/${this.uid}/settings/search-cutoff-ms`
return await this.httpRequest.get<SearchCutoffMs>(url)
}

/**
* Update the SearchCutoffMs settings.
*
* @param searchCutoffMs - Object containing SearchCutoffMsSettings
* @returns Promise containing an EnqueuedTask
*/
async updateSearchCutoffMs(
searchCutoffMs: SearchCutoffMs
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/search-cutoff-ms`
const task = await this.httpRequest.put(url, searchCutoffMs)

return new EnqueuedTask(task)
}

/**
* Reset the SearchCutoffMs settings.
*
* @returns Promise containing an EnqueuedTask
*/
async resetSearchCutoffMs(): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/search-cutoff-ms`
const task = await this.httpRequest.delete(url)

return new EnqueuedTask(task)
}
}

export { Index }
41 changes: 40 additions & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export type SearchResponse<
query: string
facetDistribution?: FacetDistribution
facetStats?: FacetStats
vector?: number[]
} & (undefined extends S
? Partial<FinitePagination & InfinitePagination>
: true extends IsFinitePagination<NonNullable<S>>
Expand Down Expand Up @@ -335,30 +334,64 @@ export type NonSeparatorTokens = string[] | null
export type Dictionary = string[] | null
export type ProximityPrecision = 'byWord' | 'byAttribute'

export type Distribution = {
mean: number
sigma: number
}

export type OpenAiEmbedder = {
source: 'openAi'
model?: string
apiKey?: string
documentTemplate?: string
dimensions?: number
distribution?: Distribution
}

export type HuggingFaceEmbedder = {
source: 'huggingFace'
model?: string
revision?: string
documentTemplate?: string
distribution?: Distribution
}

export type UserProvidedEmbedder = {
source: 'userProvided'
dimensions: number
distribution?: Distribution
}

export type RestEmbedder = {
source: 'rest'
url: string
apiKey?: string
dimensions?: number
documentTemplate?: string
inputField?: string[] | null
inputType?: 'text' | 'textArray'
query?: Record<string, any> | null
pathToEmbeddings?: string[] | null
embeddingObject?: string[] | null
distribution?: Distribution
}

export type OllamaEmbedder = {
source: 'ollama'
url?: string
apiKey?: string
model?: string
documentTemplate?: string
distribution?: Distribution
}

export type Embedder =
| OpenAiEmbedder
| HuggingFaceEmbedder
| UserProvidedEmbedder
| RestEmbedder
| OllamaEmbedder
| null

export type Embedders = Record<string, Embedder> | null

Expand All @@ -373,6 +406,8 @@ export type PaginationSettings = {
maxTotalHits?: number | null
}

export type SearchCutoffMs = number | null

export type Settings = {
filterableAttributes?: FilterableAttributes
distinctAttribute?: DistinctAttribute
Expand All @@ -390,6 +425,7 @@ export type Settings = {
dictionary?: Dictionary
proximityPrecision?: ProximityPrecision
embedders?: Embedders
searchCutoffMs?: SearchCutoffMs
}

/*
Expand Down Expand Up @@ -930,6 +966,9 @@ export const ErrorStatusCode = {
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_pagination */
INVALID_SETTINGS_PAGINATION: 'invalid_settings_pagination',

/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_search_cutoff_ms */
INVALID_SETTINGS_SEARCH_CUTOFF_MS: 'invalid_settings_search_cutoff_ms',

/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_before_enqueued_at */
INVALID_TASK_BEFORE_ENQUEUED_AT: 'invalid_task_before_enqueued_at',

Expand Down
Loading

0 comments on commit 6a97984

Please sign in to comment.