Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(collection): add flag to reindex collection after an update #749

Merged
merged 2 commits into from
Oct 1, 2024
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
1 change: 0 additions & 1 deletion .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ runs:
- name: Run tests
run: |
npm run test:unit
cat ./coverage/lcov.info | ./node_modules/.bin/codecov
shell: bash
65 changes: 31 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<a href="https://travis-ci.org/kuzzleio/sdk-javascript">
<img src="https://travis-ci.org/kuzzleio/sdk-javascript.svg?branch=master"/>
</a>
<a href="https://codecov.io/gh/kuzzleio/sdk-javascript">
<img src="https://codecov.io/gh/kuzzleio/sdk-javascript/branch/master/graph/badge.svg" />
</a>
<a href="https://david-dm.org/kuzzleio/sdk-javascript">
<img src="https://david-dm.org/kuzzleio/sdk-javascript.svg" />
</a>
Expand All @@ -24,8 +21,8 @@ This is the official Javascript SDK for the free and open-source backend Kuzzle.

#### Multiprotocols

Currently, the SDK provides 2 protocols: __Http and WebSocket.__
WebSocket protocol implement the whole Kuzzle API, while the HTTP protocol does not implement realtime features (rooms and subscriptions).
Currently, the SDK provides 2 protocols: **Http and WebSocket.**
WebSocket protocol implement the whole Kuzzle API, while the HTTP protocol does not implement realtime features (rooms and subscriptions).

#### Promises based

Expand All @@ -42,11 +39,10 @@ Any error must be caught either at the end of the `Promise` chain, or by using `
Kuzzle is an open-source backend that includes a scalable server, a multiprotocol API,
an administration console and a set of plugins that provide advanced functionalities like real-time pub/sub, blazing fast search and geofencing.

* :octocat: __[Github](https://github.com/kuzzleio/kuzzle)__
* :earth_africa: __[Website](https://kuzzle.io)__
* :books: __[Documentation](https://docs.kuzzle.io)__
* :email: __[Discord](http://join.discord.kuzzle.io)__

- :octocat: **[Github](https://github.com/kuzzleio/kuzzle)**
- :earth_africa: **[Website](https://kuzzle.io)**
- :books: **[Documentation](https://docs.kuzzle.io)**
- :email: **[Discord](http://join.discord.kuzzle.io)**

## Get trained by the creators of Kuzzle :zap:

Expand All @@ -59,36 +55,38 @@ Our teams will be able to meet your needs in terms of expertise and multi-techno
## Compatibility matrix

| Kuzzle Version | SDK Version |
|----------------|-------------|
| -------------- | ----------- |
| 1.x.x | 5.x.x |
| 1.x.x | 6.x.x |
| 2.x.x | 7.x.x |

## Getting started :point_right:

- [Node.js](https://docs.kuzzle.io/sdk/js/7/getting-started/node-js/)
- [Browser](https://docs.kuzzle.io/sdk/js/7/getting-started/raw-web/)
- [Webpack](https://docs.kuzzle.io/sdk/js/7/getting-started/webpack/)
- [React/Redux](https://docs.kuzzle.io/sdk/js/7/getting-started/react/with-redux/)
- [Vue.js](https://docs.kuzzle.io/sdk/js/7/getting-started/vuejs/standalone/)
- [Node.js](https://docs.kuzzle.io/sdk/js/7/getting-started/node-js/)
- [Browser](https://docs.kuzzle.io/sdk/js/7/getting-started/raw-web/)
- [Webpack](https://docs.kuzzle.io/sdk/js/7/getting-started/webpack/)
- [React/Redux](https://docs.kuzzle.io/sdk/js/7/getting-started/react/with-redux/)
- [Vue.js](https://docs.kuzzle.io/sdk/js/7/getting-started/vuejs/standalone/)

### Installation

This SDK can be used either in NodeJS or in a browser.

#### Node.js
#### Node.js

```
npm install kuzzle-sdk
```

#### Browser

To run the SDK in the browser, you have to build it yourself by cloning this repository and running
To run the SDK in the browser, you have to build it yourself by cloning this repository and running

```bash
$ npm install
$ npm run build
````
```

A `dist` directory will be created, containing a browser version of this SDK.

```html
Expand All @@ -98,18 +96,19 @@ A `dist` directory will be created, containing a browser version of this SDK.
or use the CDN:

```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kuzzle-sdk@latest/dist/kuzzle.min.js"></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/kuzzle-sdk@latest/dist/kuzzle.min.js"
></script>
```

Then the Kuzzle SDK will be available under the `KuzzleSDK` variable:

```html
<script>
const kuzzle = new KuzzleSDK.Kuzzle(
new KuzzleSDK.WebSocket('localhost')
);
// ...
</script>
<script>
const kuzzle = new KuzzleSDK.Kuzzle(new KuzzleSDK.WebSocket("localhost"));
// ...
</script>
```

#### Browser with Webpack
Expand All @@ -124,21 +123,19 @@ But you'll still need to pick the built version (which ships with the package).

```javascript
// with the classic require...
const { Kuzzle } = require('kuzzle-sdk')
const { Kuzzle } = require("kuzzle-sdk");
// ... or with the new import directive.
import { Kuzzle } from 'kuzzle-sdk'
import { Kuzzle } from "kuzzle-sdk";
```

### Example

The SDK supports different protocols. When instantiating,
you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.
The SDK supports different protocols. When instantiating,
you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.

```js
const { Kuzzle, WebSocket } = require('kuzzle-sdk');
const kuzzle = new Kuzzle(
new WebSocket('localhost', { port: 7512 })
);
const { Kuzzle, WebSocket } = require("kuzzle-sdk");
const kuzzle = new Kuzzle(new WebSocket("localhost", { port: 7512 }));

try {
await kuzzle.connect();
Expand Down
42 changes: 22 additions & 20 deletions doc/7/controllers/collection/update/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ update(index, collection, definition);
<br/>

| 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 |
Expand All @@ -37,39 +37,41 @@ update(index, collection, definition);

Additional query options

| Options | Type<br/>(default) | Description |
| ---------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
| [`timeout`](/sdk/7/core-classes/kuzzle/query#timeout) | <pre>number</pre> | Time (in ms) during which a request will still be waited to be resolved. Set it `-1` if you want to wait indefinitely |

| Options | Type<br/>(default) | Description |
| ----------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
| [`timeout`](/sdk/7/core-classes/kuzzle/query#timeout) | <pre>number</pre> | Time (in ms) during which a request will still be waited to be resolved. Set it `-1` if you want to wait indefinitely |

<SinceBadge version="7.4.0">

### definition

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

- [collection mappings](/core/2/guides/main-concepts/data-storage).
- Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
- `reindexCollection` (optional): if set to `true`, Kuzzle will reindex the collection after updating the mappings. This is useful when you want to update the mappings of a collection that already contains data.

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

</SinceBadge>

<DeprecatedBadge version="7.4.0" >
Expand All @@ -83,13 +85,13 @@ The mappings must have a root field `properties` that contain the mappings prope
```js
const mappings = {
properties: {
field1: { type: 'text' },
field1: { type: "text" },
field2: {
properties: {
nestedField: { type: 'keyword' }
}
}
}
nestedField: { type: "keyword" },
},
},
},
};
```

Expand Down
Loading
Loading