-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
kibana_index_mappings_mixin.js
60 lines (56 loc) · 1.75 KB
/
kibana_index_mappings_mixin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { IndexMappings } from './index_mappings';
/**
* The default mappings used for the kibana index. This is
* extended via uiExports type "mappings". See the kibana
* and timelion plugins for examples.
* @type {EsMappingDsl}
*/
const BASE_KIBANA_INDEX_MAPPINGS_DSL = {
doc: {
'dynamic': 'strict',
properties: {
type: {
type: 'keyword'
},
config: {
dynamic: true,
properties: {
buildNum: {
type: 'keyword'
}
}
},
}
}
};
export function kibanaIndexMappingsMixin(kbnServer, server) {
/**
* Stores the current mappings that we expect to find in the Kibana
* index. Using `kbnServer.mappings.addRootProperties()` the UiExports
* class extends these mappings based on `mappings` ui export specs.
*
* Application code should not access this object, and instead should
* use `server.getKibanaIndexMappingsDsl()` from below, mixed with the
* helpers exposed by this module, to interact with the mappings via
* their DSL.
*
* @type {IndexMappings}
*/
kbnServer.mappings = new IndexMappings(BASE_KIBANA_INDEX_MAPPINGS_DSL);
/**
* Get the mappings dsl that we expect to see in the
* Kibana index. Used by the elasticsearch plugin to create
* and update the kibana index. Also used by the SavedObjectsClient
* to determine the properties defined in the mapping as well as
* things like the "rootType".
*
* See `src/server/mappings/lib/index.js` for helpers useful for reading
* the EsMappingDsl object.
*
* @method server.getKibanaIndexMappingsDsl
* @returns {EsMappingDsl}
*/
server.decorate('server', 'getKibanaIndexMappingsDsl', () => {
return kbnServer.mappings.getDsl();
});
}