Commit 7057910f authored by Julien Bouquillon's avatar Julien Bouquillon 🐫
Browse files

fix: env vars

parent 0aae594a
......@@ -33,5 +33,7 @@ Now we use the assembled CSV file to populate an Elastic index. Within the `inde
yarn install
yarn build
ELASTICSEARCH_URL=https://elastic_url:9200 API_KEY=key_with_writing_rights ASSEMBLY_FILE=/path_to/assembly.csv node dist/index.js
ELASTICSEARCH_URL=https://elastic_url:9200 ELASTICSEARCH_API_KEY=key_with_writing_rights ASSEMBLY_FILE=/path_to/assembly.csv node dist/index.js
```
The default `ELASTICSEARCH_INDEX_NAME` is `recherche-entreprises`
......@@ -5,7 +5,7 @@ Exemple d'API qui exploite l'index ElasticSearch [recherche-entreprises](https:/
```sh
yarn install
yarn build
ELASTICSEARCH_URL=http://localhost:9200 API_KEY=key yarn start
ELASTICSEARCH_URL=http://localhost:9200 ELASTICSEARCH_API_KEY=key yarn start
```
## **Generic search**
......
const { Client } = require("@elastic/elasticsearch");
const ELASTICSEARCH_URL =
process.env.ELASTICSEARCH_URL || "http://localhost:9200";
const API_KEY = process.env.API_KEY;
const API_KEY = process.env.ELASTICSEARCH_API_KEY;
const auth = API_KEY ? { apiKey: API_KEY } : undefined;
export const ELASTICSEARCH_INDEX =
process.env.ELASTICSEARCH_INDEX || "cdtn-siren";
process.env.ELASTICSEARCH_INDEX || "recherche-entreprises";
const esClientConfig = {
node: `${ELASTICSEARCH_URL}`,
......
......@@ -16,11 +16,11 @@
"@elastic/elasticsearch": "^7.10.0",
"@socialgouv/kali-data": "^2.55.0",
"fast-csv": "^4.3.6",
"tslab": "^1.0.15"
"tslab": "^1.0.15",
"ts-node": "^9.1.1"
},
"devDependencies": {
"@vercel/ncc": "^0.28.2",
"ts-node": "^9.1.1",
"tslint": "^6.1.3",
"typescript": "^4.1.3"
}
......
// assemble data from different sources to create our index
......@@ -3,9 +3,9 @@ import { Enterprise, mapEnterprise, mappings } from "./enterprise";
const ELASTICSEARCH_URL =
process.env.ELASTICSEARCH_URL || "http://localhost:9200";
const API_KEY = process.env.API_KEY;
const API_KEY = process.env.ELASTICSEARCH_API_KEY;
const indexName = "cdtn-siren";
const indexName = process.env.ELASTICSEARCH_INDEX_NAME || "recherche-entreprises";
const auth = API_KEY ? { apiKey: API_KEY } : undefined;
......
......@@ -35,4 +35,6 @@ const parseEnterprises = () => {
);
};
resetIndex().then(() => parseEnterprises());
if (require.main === module) {
resetIndex().then(() => parseEnterprises());
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment