From 79cf4f15d89c8236f667de04265af0cd37e62638 Mon Sep 17 00:00:00 2001 From: Emerson Rocha Luiz Date: Fri, 12 Oct 2018 22:22:27 -0300 Subject: [PATCH] Use release version v1.2 of Uwazi; removed patched reindex_elastic.js file #17 --- Dockerfile | 6 +- .../patch/uwazi/database/reindex_elastic.js | 61 ------------------- 2 files changed, 2 insertions(+), 65 deletions(-) delete mode 100644 scripts/patch/uwazi/database/reindex_elastic.js diff --git a/Dockerfile b/Dockerfile index 2643b25..724db78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,15 +10,13 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ git \ libpng-dev -## Download Uwazi -RUN git clone -b 1.1 --single-branch --depth=1 https://github.com/huridocs/uwazi.git /home/node/uwazi/ \ +## Download Uwazi v1.2 +RUN git clone -b v1.2 --single-branch --depth=1 https://github.com/huridocs/uwazi.git /home/node/uwazi/ \ && chown node:node -R /home/node/uwazi/ \ && cd /home/node/uwazi/ \ && yarn install \ && yarn production-build -COPY --chown=node:node ./scripts/patch/uwazi/database/reindex_elastic.js /home/node/uwazi/database/reindex_elastic.js - ## TODO: move to the start of the Dockerfile (fititnt, 2018-04-16 00:27 BRT) # Install mongo & mongorestore (this is used only for database initialization, not on runtime) # So much space need, see 'After this operation, 184 MB of additional disk space will be used.' diff --git a/scripts/patch/uwazi/database/reindex_elastic.js b/scripts/patch/uwazi/database/reindex_elastic.js deleted file mode 100644 index 4a1a274..0000000 --- a/scripts/patch/uwazi/database/reindex_elastic.js +++ /dev/null @@ -1,61 +0,0 @@ -import mongoose from 'mongoose'; -import connect from './connect_to_mongo'; -import request from '../app/shared/JSONRequest'; -import search from '../app/api/search/search'; -import elasticMapping from './elastic_mapping'; - -import indexConfig from '../app/api/config/elasticIndexes'; -import entities from '../app/api/entities/entities'; - -connect() -.then(() => { - const limit = 200; - let docsIndexed = 0; - let pos = 0; - const spinner = ['|', '/', '-', '\\']; - - function migrate(offset, totalRows) { - return entities.get({}, '+fullText', { skip: offset, limit }) - .then((docsResponse) => { - if (offset >= totalRows) { - return Promise.resolve(); - } - - return search.bulkIndex(docsResponse, 'index') - .then(() => { - process.stdout.write(`Indexing documents and entities... ${spinner[pos]} - ${docsIndexed} indexed\r`); - pos += 1; - if (pos > 3) { - pos = 0; - } - docsIndexed += docsResponse.length; - return migrate(offset + limit, totalRows); - }) - .catch((err) => { - console.log('ERR:', err); - }); - }); - } - - const start = Date.now(); - process.stdout.write(`Deleting index... ${indexConfig.index}\n`); - const elasticUrl = process.env.ELASTICSEARCH_URL || 'http://localhost:9200'; - const indexUrl = `${elasticUrl}/${indexConfig.index}`; - request.delete(indexUrl) - .catch(console.log) - .then(() => { - process.stdout.write(`Creating index... ${indexConfig.index}\n`); - return request.put(indexUrl, elasticMapping).catch(console.log); - }) - .then(() => entities.count() - .then(totalRows => migrate(0, totalRows) - .catch((error) => { - console.log('Migration error: ', error); - }))) - .then(() => { - const end = Date.now(); - process.stdout.write(`Indexing documents and entities... - ${docsIndexed} indexed\r\n`); - process.stdout.write(`Done, took ${(end - start) / 1000} seconds\n`); - mongoose.disconnect(); - }); -}); \ No newline at end of file