Files
docker-compose-hatthieves/production/arjion/arjion/lib/elastic.js
Your Name ada9dd5fa7 arjion
2020-05-27 17:44:02 +00:00

108 líneas
4.5 KiB
JavaScript

module.exports = (config, client6) => {
(async () => {
const exist = await client6.indices.exists({
index: config.index
})
if (!exist.body) {
await client6.indices.create({
index: config.index,
body: {
settings: {
number_of_shards: 1,
number_of_replicas: 0
},
mappings: {
user: {
dynamic_templates: [
{
metadata_as_keywords: {
path_match: 'documents.metadata.*',
mapping: {
type: 'keyword'
}
}
}
],
properties: {
date: {
type: 'date',
format: 'dd-MM-yyyy HH:mm:ss||dd-MM-yyyy||epoch_millis'
},
user: {
type: 'text',
fielddata: true
},
password: {
type: 'keyword'
},
email: {
type: 'text'
},
verified: {
type: 'boolean'
},
verify_link: {
type: 'text'
},
locked: {
type: 'boolean'
},
documents: {
type: 'nested',
properties: {
date: {
type: 'date',
format: 'dd-MM-yyyy HH:mm:ss||dd-MM-yyyy||epoch_millis'
},
originalname: {
type: 'text'
},
filename: {
type: 'text'
},
path: {
type: 'text'
},
mimetype: {
type: 'text'
},
size: {
type: 'long'
},
metadata: {
type: 'object'
},
language: {
type: 'text'
},
sha256: {
type: 'text'
},
deleted: {
type: 'boolean'
}
}
}
}
}
}
}
}).catch(err => console.error)
await client6.index({
index: config.index,
type: config.type,
body: {
date: Date.now(),
user: config.anonymous,
password: null,
email: null,
verified: true,
verify_link: null,
documents: [],
locked: false
},
refresh: true
}).catch(err => console.error)
}
})()
}