Skip to content

Commit d5990ea

Browse files
authored
Merge pull request #749 from kuzzleio/feature/517-update-mapping-reindexCollection-flag
2 parents fe7be9d + 9b19a44 commit d5990ea

File tree

6 files changed

+63
-205
lines changed

6 files changed

+63
-205
lines changed

.github/actions/unit-tests/action.yml

-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ runs:
1111
- name: Run tests
1212
run: |
1313
npm run test:unit
14-
cat ./coverage/lcov.info | ./node_modules/.bin/codecov
1514
shell: bash

README.md

+31-34
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
<a href="https://travis-ci.org/kuzzleio/sdk-javascript">
66
<img src="https://travis-ci.org/kuzzleio/sdk-javascript.svg?branch=master"/>
77
</a>
8-
<a href="https://codecov.io/gh/kuzzleio/sdk-javascript">
9-
<img src="https://codecov.io/gh/kuzzleio/sdk-javascript/branch/master/graph/badge.svg" />
10-
</a>
118
<a href="https://david-dm.org/kuzzleio/sdk-javascript">
129
<img src="https://david-dm.org/kuzzleio/sdk-javascript.svg" />
1310
</a>
@@ -24,8 +21,8 @@ This is the official Javascript SDK for the free and open-source backend Kuzzle.
2421

2522
#### Multiprotocols
2623

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

3027
#### Promises based
3128

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

45-
* :octocat: __[Github](https://github.com/kuzzleio/kuzzle)__
46-
* :earth_africa: __[Website](https://kuzzle.io)__
47-
* :books: __[Documentation](https://docs.kuzzle.io)__
48-
* :email: __[Discord](http://join.discord.kuzzle.io)__
49-
42+
- :octocat: **[Github](https://github.com/kuzzleio/kuzzle)**
43+
- :earth_africa: **[Website](https://kuzzle.io)**
44+
- :books: **[Documentation](https://docs.kuzzle.io)**
45+
- :email: **[Discord](http://join.discord.kuzzle.io)**
5046

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

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

6157
| Kuzzle Version | SDK Version |
62-
|----------------|-------------|
58+
| -------------- | ----------- |
6359
| 1.x.x | 5.x.x |
6460
| 1.x.x | 6.x.x |
6561
| 2.x.x | 7.x.x |
6662

6763
## Getting started :point_right:
6864

69-
- [Node.js](https://docs.kuzzle.io/sdk/js/7/getting-started/node-js/)
70-
- [Browser](https://docs.kuzzle.io/sdk/js/7/getting-started/raw-web/)
71-
- [Webpack](https://docs.kuzzle.io/sdk/js/7/getting-started/webpack/)
72-
- [React/Redux](https://docs.kuzzle.io/sdk/js/7/getting-started/react/with-redux/)
73-
- [Vue.js](https://docs.kuzzle.io/sdk/js/7/getting-started/vuejs/standalone/)
65+
- [Node.js](https://docs.kuzzle.io/sdk/js/7/getting-started/node-js/)
66+
- [Browser](https://docs.kuzzle.io/sdk/js/7/getting-started/raw-web/)
67+
- [Webpack](https://docs.kuzzle.io/sdk/js/7/getting-started/webpack/)
68+
- [React/Redux](https://docs.kuzzle.io/sdk/js/7/getting-started/react/with-redux/)
69+
- [Vue.js](https://docs.kuzzle.io/sdk/js/7/getting-started/vuejs/standalone/)
7470

7571
### Installation
7672

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

79-
#### Node.js
75+
#### Node.js
8076

8177
```
8278
npm install kuzzle-sdk
8379
```
8480

8581
#### Browser
8682

87-
To run the SDK in the browser, you have to build it yourself by cloning this repository and running
83+
To run the SDK in the browser, you have to build it yourself by cloning this repository and running
84+
8885
```bash
8986
$ npm install
9087
$ npm run build
91-
````
88+
```
89+
9290
A `dist` directory will be created, containing a browser version of this SDK.
9391

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

10098
```html
101-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kuzzle-sdk@latest/dist/kuzzle.min.js"></script>
99+
<script
100+
type="text/javascript"
101+
src="https://cdn.jsdelivr.net/npm/kuzzle-sdk@latest/dist/kuzzle.min.js"
102+
></script>
102103
```
103104

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

106107
```html
107-
<script>
108-
const kuzzle = new KuzzleSDK.Kuzzle(
109-
new KuzzleSDK.WebSocket('localhost')
110-
);
111-
// ...
112-
</script>
108+
<script>
109+
const kuzzle = new KuzzleSDK.Kuzzle(new KuzzleSDK.WebSocket("localhost"));
110+
// ...
111+
</script>
113112
```
114113

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

125124
```javascript
126125
// with the classic require...
127-
const { Kuzzle } = require('kuzzle-sdk')
126+
const { Kuzzle } = require("kuzzle-sdk");
128127
// ... or with the new import directive.
129-
import { Kuzzle } from 'kuzzle-sdk'
128+
import { Kuzzle } from "kuzzle-sdk";
130129
```
131130

132131
### Example
133132

134-
The SDK supports different protocols. When instantiating,
135-
you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.
133+
The SDK supports different protocols. When instantiating,
134+
you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.
136135

137136
```js
138-
const { Kuzzle, WebSocket } = require('kuzzle-sdk');
139-
const kuzzle = new Kuzzle(
140-
new WebSocket('localhost', { port: 7512 })
141-
);
137+
const { Kuzzle, WebSocket } = require("kuzzle-sdk");
138+
const kuzzle = new Kuzzle(new WebSocket("localhost", { port: 7512 }));
142139

143140
try {
144141
await kuzzle.connect();

doc/7/controllers/collection/update/index.md

+22-20
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ update(index, collection, definition);
2727
<br/>
2828

2929
| Arguments | Type | Description |
30-
|--------------|-------------------|-------------------------------------------------------------|
30+
| ------------ | ----------------- | ----------------------------------------------------------- |
3131
| `index` | <pre>string</pre> | Index name |
3232
| `collection` | <pre>string</pre> | Collection name |
3333
| `definition` | <pre>object</pre> | Describes the collection mappings and the ES index settings |
@@ -37,39 +37,41 @@ update(index, collection, definition);
3737

3838
Additional query options
3939

40-
| Options | Type<br/>(default) | Description |
41-
| ---------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
42-
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
43-
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
44-
| [`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 |
45-
40+
| Options | Type<br/>(default) | Description |
41+
| ----------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
42+
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
43+
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
44+
| [`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 |
4645

4746
<SinceBadge version="7.4.0">
4847

4948
### definition
5049

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

52+
- [collection mappings](/core/2/guides/main-concepts/data-storage).
53+
- Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
54+
- `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.
5555

5656
```js
5757
const definition = {
5858
mappings: {
5959
properties: {
60-
field1: { type: 'text' },
60+
field1: { type: "text" },
6161
field2: {
6262
properties: {
63-
nestedField: { type: 'keyword' }
64-
}
65-
}
66-
}
63+
nestedField: { type: "keyword" },
64+
},
65+
},
66+
},
6767
},
68+
reindexCollection: true,
6869
settings: {
6970
// index settings (e.g. analyzers)
70-
}
71+
},
7172
};
7273
```
74+
7375
</SinceBadge>
7476

7577
<DeprecatedBadge version="7.4.0" >
@@ -83,13 +85,13 @@ The mappings must have a root field `properties` that contain the mappings prope
8385
```js
8486
const mappings = {
8587
properties: {
86-
field1: { type: 'text' },
88+
field1: { type: "text" },
8789
field2: {
8890
properties: {
89-
nestedField: { type: 'keyword' }
90-
}
91-
}
92-
}
91+
nestedField: { type: "keyword" },
92+
},
93+
},
94+
},
9395
};
9496
```
9597

0 commit comments

Comments
 (0)