Skip to content
Open
Show file tree
Hide file tree
Changes from 22 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
12 changes: 6 additions & 6 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ date_guide_sort_1: |-
sort: ['release_timestamp:desc'],
})
get_one_index_1: |-
client.index('movies').getRawInfo()
client.index('movies').getIndex()
list_all_indexes_1: |-
client.getIndexes({ limit: 3 })
create_an_index_1: |-
client.createIndex('movies', { primaryKey: 'id' })
client.createIndex({ uid: 'movies', primaryKey: 'id' })
update_an_index_1: |-
client.updateIndex('movies', { primaryKey: 'id' })
client.index('movies').updateIndex({ primaryKey: 'id' })
delete_an_index_1: |-
client.deleteIndex('movies')
client.index('movies').deleteIndex()
swap_indexes_1: |-
client.swapIndexes([
{ 'indexes': ['indexA', 'indexB'] },
Expand Down Expand Up @@ -402,11 +402,11 @@ add_movies_json_1: |-
const movies = require('./movies.json')
client.index('movies').addDocuments(movies).then((res) => console.log(res))
primary_field_guide_update_document_primary_key: |-
client.updateIndex('books', {
client.index('books').updateIndex({
primaryKey: 'title'
})
primary_field_guide_create_index_primary_key: |-
client.createIndex('books', { primaryKey: 'reference_number' })
client.createIndex({ uid: 'books', primaryKey: 'reference_number' })
primary_field_guide_add_document_primary_key: |-
client.index('books').addDocuments([
{
Expand Down
54 changes: 5 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,23 +592,17 @@ client.getBatches(parameters: BatchesQuery = {}): Promise<BatchesResults>

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

#### [Get all indexes in Index instances](https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes)

```ts
client.getIndexes(parameters: IndexesQuery): Promise<IndexesResults<Index[]>>
```

#### [Get all indexes](https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes)

```ts
client.getRawIndexes(parameters: IndexesQuery): Promise<IndexesResults<IndexObject[]>>
client.getIndexes(listIndexes?: ListIndexes): Promise<IndexViewList>
```


#### [Create a new index](https://www.meilisearch.com/docs/reference/api/indexes#create-an-index)

```ts
client.createIndex<T>(uid: string, options?: IndexOptions): Promise<EnqueuedTask>
client.createIndex(indexCreateRequest: IndexCreateRequest): EnqueuedTaskPromise
```

#### Create a local reference to an index
Expand All @@ -617,48 +611,22 @@ client.createIndex<T>(uid: string, options?: IndexOptions): Promise<EnqueuedTask
client.index<T>(uid: string): Index<T>
```

#### [Get an index instance completed with information fetched from Meilisearch](https://www.meilisearch.com/docs/reference/api/indexes#get-one-index)

```ts
client.getIndex<T>(uid: string): Promise<Index<T>>
```

#### [Get the raw index JSON response from Meilisearch](https://www.meilisearch.com/docs/reference/api/indexes#get-one-index)

```ts
client.getRawIndex(uid: string): Promise<IndexObject>
```

#### [Get an object with information about the index](https://www.meilisearch.com/docs/reference/api/indexes#get-one-index)

```ts
client.index('myIndex').getRawInfo(): Promise<IndexObject>
client.index(uid: string).getIndex(): Promise<IndexView>
```

#### [Update Index](https://www.meilisearch.com/docs/reference/api/indexes#update-an-index)

##### Using the client

```ts
client.updateIndex(uid: string, options: IndexOptions): Promise<EnqueuedTask>
```

##### Using the index object

```ts
client.index('myIndex').update(data: IndexOptions): Promise<EnqueuedTask>
client.index(uid: string).updateIndex(updateIndexRequest?: UpdateIndexRequest): EnqueuedTaskPromise
```

#### [Delete index](https://www.meilisearch.com/docs/reference/api/indexes#delete-an-index)

##### Using the client
```ts
client.deleteIndex(uid): Promise<void>
```

##### Using the index object
```ts
client.index('myIndex').delete(): Promise<void>
client.index(uid: string).deleteIndex(): EnqueuedTaskPromise
```

#### [Get specific index stats](https://www.meilisearch.com/docs/reference/api/stats#get-stats-of-an-index)
Expand All @@ -667,18 +635,6 @@ client.index('myIndex').delete(): Promise<void>
client.index('myIndex').getStats(): Promise<IndexStats>
```

##### Return Index instance with updated information

```ts
client.index('myIndex').fetchInfo(): Promise<Index>
```

##### Get Primary Key of an Index

```ts
client.index('myIndex').fetchPrimaryKey(): Promise<string | undefined>
```

##### Swap two indexes

```ts
Expand Down
4 changes: 2 additions & 2 deletions playgrounds/javascript/src/meilisearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const index = client.index<{ id: number; title: string; genres: string[] }>(
);

export async function addDocuments(): Promise<void> {
await client.deleteIndexIfExists(indexUid);
await client.index(indexUid).deleteIndex().waitTask();

await client.createIndex(indexUid).waitTask();
await client.createIndex({ uid: indexUid }).waitTask();

await index
.addDocuments([
Expand Down
Loading