Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ src/Kuzzle.js
src/KuzzleError.js
src/controllers/Auth.js
src/controllers/Document.js
src/controllers/Index.js
src/controllers/Collection.js
src/controllers/Base.js
src/core/security/User.js
src/core/security/Profile.js
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ src/Kuzzle.js
src/KuzzleError.js
src/controllers/Auth.js
src/controllers/Document.js
src/controllers/Index.js
src/controllers/Collection.js
src/controllers/Base.js
src/core/security/User.js
src/core/security/Profile.js
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
- $(npm bin)/kuzdoc framework:link -d /sdk/js/7/ -v 7
script:
- gem install typhoeus
- cd doc/framework/ && HYDRA_MAX_CONCURRENCY=20 ruby .ci/dead-links.rb -p src/sdk/js/7/
- cd doc/framework/ && HYDRA_MAX_CONCURRENCY=20 travis_retry ruby .ci/dead-links.rb -p src/sdk/js/7/

- stage: Deployment Doc Dev
name: Deploy next-docs.kuzzle.io
Expand Down
54 changes: 46 additions & 8 deletions doc/7/controllers/collection/create/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ description: Create a new collection

# create

Creates a new [collection](/core/2/guides/essentials/store-access-data) in Kuzzle via the persistence engine, in the provided index.
Creates a new [collection](/core/2/guides/essentials/store-access-data) in the provided index.

You can also provide an optional data mapping that allow you to exploit the full capabilities of our
persistent data storage layer, [ElasticSearch](https://www.elastic.co/elastic-stack) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/mapping.html)).
persistent data storage layer, [ElasticSearch](https://www.elastic.co/elastic-stack) (check here the [mapping capabilities of ElasticSearch](/core/2/guides/essentials/database-mappings/)).

This method will only update the mapping if the collection already exists.

<SinceBadge version="Kuzzle 2.2.0" />
<SinceBadge version="auto-version" />

You can also provide Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings) when creating a new collection.

<br/>

```js
create(index, collection, [mapping], [options]);
create(index, collection, [definition], [options]);
```

<br/>
Expand All @@ -26,17 +31,48 @@ create(index, collection, [mapping], [options]);
| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |
| `mapping` | <pre>object</pre> | Describes the data mapping to associate to the new collection, using Elasticsearch [mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/mapping.html) |
| `definition` | <pre>object</pre> | Describes the collection mappings and the ES index settings |
| `options` | <pre>object</pre> | Query options |
<SinceBadge version="auto-version">

### mapping

An object representing the data mapping of the collection.
### definition

An object containings:
- [collection mappings](/core/2/guides/essentials/database-mappings).
- Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
The mapping must have a root field `properties` that contain the mapping definition:

```js
const mapping = {
const definition = {
mappings: {
properties: {
field1: { type: 'text' },
field2: {
properties: {
nestedField: { type: 'keyword' }
}
}
}
},
settings: {

}
};
```

</SinceBadge>


<DeprecatedBadge version="auto-version">

### definition

An object representing the data mappings of the collection.

The mappings must have a root field `properties` that contain the mappings properties definition:

```js
const mappings = {
properties: {
field1: { type: 'text' },
field2: {
Expand All @@ -50,6 +86,8 @@ const mapping = {

More informations about database mappings [here](/core/2/guides/essentials/database-mappings).

</DeprecatedBadge>

### options

Additional query options
Expand Down
4 changes: 2 additions & 2 deletions doc/7/controllers/collection/create/snippets/create.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const mapping = {
const mappings = {
properties: {
license: { type: 'keyword' },
driver: {
Expand All @@ -11,7 +11,7 @@ const mapping = {
};

try {
await kuzzle.collection.create('nyc-open-data', 'yellow-taxi', mapping);
await kuzzle.collection.create('nyc-open-data', 'yellow-taxi', { mappings });

console.log('Success');
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/collection/exists/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Check if collection exists

# exists

Check if a collection exists in Kuzzle.
Checks if a collection exists in Kuzzle.

<br/>

Expand Down
1 change: 1 addition & 0 deletions doc/7/controllers/collection/get-mapping/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Additional query options
| Property | Type<br/>(default) | Description |
| ---------- | ------------------------------- | ---------------------------------------------------------------------------- |
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
| `includeKuzzleMeta` | <pre>boolean</pre><br/>(`true`) | If true, the returned mappings will contain [Kuzzle metadata](/core/2/guides/essentials/document-metadata/) |

## Resolves

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/collection/refresh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Forces an Elasticsearch search index update

# refresh

When writing or deleting documents in Kuzzle, the update needs to be indexed before being available in search results.
Refreshes a collection to reindex the written and deleted documents so they are available in search results.

:::info
A refresh operation comes with some performance costs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Update the validation specifications

# updateSpecifications

The updateSpecifications method allows you to create or update the validation specifications for a collection.
Creates or updates the validation specifications for a collection.

When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug.

Expand Down
61 changes: 51 additions & 10 deletions doc/7/controllers/collection/update/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,66 @@ You can define the collection [dynamic mapping policy](/core/2/guides/essentials

You can define [collection additional metadata](/core/2/guides/essentials/database-mappings#collection-metadata) within the `_meta` root field.

<SinceBadge version="Kuzzle 2.2.0" />
<SinceBadge version="auto-version" />

You can also provide Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings) when creating a new collection.

<br/>

```js
update(index, collection, mapping);
update(index, collection, definition);
```

<br/>

| Arguments | Type | Description |
| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |
| `mapping` | <pre>object</pre> | Describes the collection mapping |
| Arguments | Type | Description |
|--------------|-------------------|-------------------------------------------------------------|
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |
| `definition` | <pre>object</pre> | Describes the collection mappings and the ES index settings |
| `options` | <pre>object</pre> | Query options |

<SinceBadge version="auto-version">

### mapping
### definition

An object representing the collection data mapping.
An object containing:
- [collection mappings](/core/2/guides/essentials/database-mappings).
- Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)

This object must have a root field `properties` that contain the mapping definition:

```js
const mapping = {
const definition = {
mappings: {
properties: {
field1: { type: 'text' },
field2: {
properties: {
nestedField: { type: 'keyword' }
}
}
}
},
settings: {
// index settings (e.g. analyzers)
}
};
```

</SinceBadge>


<DeprecatedBadge version="auto-version">

### definition

An object representing the data mappings of the collection.

The mappings must have a root field `properties` that contain the mappings properties definition:

```js
const mappings = {
properties: {
field1: { type: 'text' },
field2: {
Expand All @@ -48,6 +86,9 @@ const mapping = {

More informations about database mappings [here](/core/2/guides/essentials/database-mappings).

</DeprecatedBadge>


## Resolves

Resolve if the collection is successfully updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Validate specifications format

# validateSpecifications

The validateSpecifications method checks if a validation specification is well formatted. It does not store or modify the existing specification.
Checks if a validation specification is well formatted. It does not store nor modify the existing specification.

When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug.

Expand Down
4 changes: 2 additions & 2 deletions src/Kuzzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export class Kuzzle extends KuzzleEventEmitter {

public auth: AuthController;
public bulk: any;
public collection: any;
public collection: CollectionController;
public document: DocumentController;
public index: any;
public index: IndexController;
public ms: any;
public realtime: any;
public security: any;
Expand Down
Loading