Skip to content

Commit

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

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

This PR:
- gathers the changes related to the next Meilisearch release (v1.6.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.6.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.6.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: Morgane Dubus <30866152+mdubus@users.noreply.github.com>
Co-authored-by: Clémentine U. - curqui <clementine@meilisearch.com>
Co-authored-by: Morgane Dubus <morgane.d@meilisearch.com>
  • Loading branch information
5 people committed Jan 15, 2024
2 parents be57d84 + e598d94 commit 1a9c032
Show file tree
Hide file tree
Showing 10 changed files with 557 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ update_non_separator_tokens_1: |-
client.index('books').updateNonSeparatorTokens(['@', '#'])
reset_non_separator_tokens_1: |-
client.index('books').resetNonSeparatorTokens()
get_proximity_precision_settings_1: |-
client.index('books').getProximityPrecision()
update_proximity_precision_settings_1: |-
client.index('books').updateProximityPrecision('byAttribute')
reset_proximity_precision_settings_1: |-
client.index('books').resetProximityPrecision()
search_parameter_guide_facet_stats_1: |-
client.index('movie_ratings').search('Batman', { facets: ['genres', 'rating'] })
geosearch_guide_filter_settings_1: |-
Expand Down
60 changes: 51 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -903,64 +903,106 @@ client.index('myIndex').resetTypoTolerance(): Promise<EnqueuedTask>

### Separator tokens <!-- omit in toc -->

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

```ts
client.index('myIndex').getSeparatorTokens(): Promise<SeparatorTokens>
```

#### Update separator tokens
#### [Update separator tokens](https://www.meilisearch.com/docs/reference/api/settings#update-separator-tokens)

```ts
client.index('myIndex').updateSeparatorTokens(separatorTokens: SeparatorTokens | null): Promise<EnqueuedTask>
```

#### Reset separator tokens
#### [Reset separator tokens](https://www.meilisearch.com/docs/reference/api/settings#reset-separator-tokens)

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

### Non Separator tokens <!-- omit in toc -->

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

```ts
client.index('myIndex').getNonSeparatorTokens(): Promise<NonSeparatorTokens>
```

#### Update non separator tokens
#### [Update non separator tokens](https://www.meilisearch.com/docs/reference/api/settings#update-non-separator-tokens)

```ts
client.index('myIndex').updateNonSeparatorTokens(nonSeparatorTokens: NonSeparatorTokens | null): Promise<EnqueuedTask>
```

#### Reset non separator tokens
#### [Reset non separator tokens](https://www.meilisearch.com/docs/reference/api/settings#reset-non-separator-tokens)

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

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

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

```ts
client.index('myIndex').getDictionary(): Promise<Dictionary>
```

#### Update dictionary
#### [Update dictionary](https://www.meilisearch.com/docs/reference/api/settings#update-dictionary)

```ts
client.index('myIndex').updateDictionary(dictionary: Dictionary | null): Promise<EnqueuedTask>
```

#### Reset dictionary
#### [Reset dictionary](https://www.meilisearch.com/docs/reference/api/settings#reset-dictionary)

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

### Proximity Precision <!-- omit in toc -->

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

```ts
client.index('myIndex').getProximityPrecision(): Promise<ProximityPrecision>
```

#### [Update proximity precision](https://www.meilisearch.com/docs/reference/api/settings#update-proximity-precision)

```ts
client.index('myIndex').updateProximityPrecision(proximityPrecision: ProximityPrecision): Promise<EnqueuedTask>
```

#### [Reset proximity precision](https://www.meilisearch.com/docs/reference/api/settings#reset-proximity-precision)

```ts
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)

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

```ts
client.index('myIndex').getEmbedders(): Promise<Embedders>
```

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

```ts
client.index('myIndex').updateEmbedders(embedders: Embedders): Promise<EnqueuedTask>
```

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

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

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

#### [Get keys](https://www.meilisearch.com/docs/reference/api/keys#get-all-keys)
Expand Down
89 changes: 88 additions & 1 deletion src/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import {
SeparatorTokens,
NonSeparatorTokens,
Dictionary,
ProximityPrecision,
Embedders,
} from './types'
import { removeUndefinedFromObject } from './utils'
import { HttpRequests } from './http-requests'
Expand Down Expand Up @@ -1222,7 +1224,7 @@ class Index<T extends Record<string, any> = Record<string, any>> {
}

/**
* Update the the dictionary settings. Overwrite the old settings.
* Update the dictionary settings. Overwrite the old settings.
*
* @param dictionary - Array that contains the new dictionary settings.
* @returns Promise containing an EnqueuedTask or null
Expand All @@ -1247,6 +1249,91 @@ class Index<T extends Record<string, any> = Record<string, any>> {

return task
}

///
/// PROXIMITY PRECISION
///

/**
* Get the proximity precision settings of a Meilisearch index.
*
* @returns Promise containing the proximity precision settings
*/
async getProximityPrecision(): Promise<ProximityPrecision> {
const url = `indexes/${this.uid}/settings/proximity-precision`
return await this.httpRequest.get<ProximityPrecision>(url)
}

/**
* Update the proximity precision settings. Overwrite the old settings.
*
* @param proximityPrecision - String that contains the new proximity
* precision settings.
* @returns Promise containing an EnqueuedTask or null
*/
async updateProximityPrecision(
proximityPrecision: ProximityPrecision
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/proximity-precision`
const task = await this.httpRequest.put(url, proximityPrecision)

return new EnqueuedTask(task)
}

/**
* Reset the proximity precision settings to its default value
*
* @returns Promise containing an EnqueuedTask
*/
async resetProximityPrecision(): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/proximity-precision`
const task = await this.httpRequest.delete<EnqueuedTask>(url)

task.enqueuedAt = new Date(task.enqueuedAt)

return task
}

///
/// EMBEDDERS
///

/**
* Get the embedders settings of a Meilisearch index.
*
* @returns Promise containing the embedders settings
*/
async getEmbedders(): Promise<Embedders> {
const url = `indexes/${this.uid}/settings/embedders`
return await this.httpRequest.get<Embedders>(url)
}

/**
* Update the embedders settings. Overwrite the old settings.
*
* @param embedders - Object that contains the new embedders settings.
* @returns Promise containing an EnqueuedTask or null
*/
async updateEmbedders(embedders: Embedders): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/embedders`
const task = await this.httpRequest.patch(url, embedders)

return new EnqueuedTask(task)
}

/**
* Reset the embedders settings to its default value
*
* @returns Promise containing an EnqueuedTask
*/
async resetEmbedders(): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/embedders`
const task = await this.httpRequest.delete<EnqueuedTask>(url)

task.enqueuedAt = new Date(task.enqueuedAt)

return task
}
}

export { Index }
36 changes: 36 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export type SearchForFacetValuesResponse = {
processingTimeMs: number
}

export type HybridSearch = {
embedder?: string
semanticRatio?: number
}

export type SearchParams = Query &
Pagination &
Highlight &
Expand All @@ -113,6 +118,7 @@ export type SearchParams = Query &
showRankingScore?: boolean
showRankingScoreDetails?: boolean
attributesToSearchOn?: string[] | null
hybrid?: HybridSearch
}

// Search parameters for searches made with the GET method
Expand All @@ -130,6 +136,8 @@ export type SearchRequestGET = Pagination &
showMatchesPosition?: boolean
vector?: string | null
attributesToSearchOn?: string | null
hybridEmbedder?: string
hybridSemanticRatio?: number
}

export type MultiSearchQuery = SearchParams & { indexUid: string }
Expand Down Expand Up @@ -316,6 +324,32 @@ export type TypoTolerance = {
export type SeparatorTokens = string[] | null
export type NonSeparatorTokens = string[] | null
export type Dictionary = string[] | null
export type ProximityPrecision = 'byWord' | 'byAttribute'

export type OpenAiEmbedder = {
source: 'openAi'
model?: string
apiKey?: string
documentTemplate?: string
}

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

export type UserProvidedEmbedder = {
source: 'userProvided'
dimensions: number
}
export type Embedder =
| OpenAiEmbedder
| HuggingFaceEmbedder
| UserProvidedEmbedder

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

export type FacetOrder = 'alpha' | 'count'

Expand Down Expand Up @@ -343,6 +377,8 @@ export type Settings = {
separatorTokens?: SeparatorTokens
nonSeparatorTokens?: NonSeparatorTokens
dictionary?: Dictionary
proximityPrecision?: ProximityPrecision
embedders?: Embedders
}

/*
Expand Down
Loading

0 comments on commit 1a9c032

Please sign in to comment.