Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Sync master with develop #57

Merged
merged 20 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c8a5248
Issue 50 - Fix issues with api (documentation)
xxcxy Oct 6, 2020
055ee11
Merge pull request #51 from topcoder-platform/Issue_50
callmekatootie Oct 7, 2020
7c965ca
Support enrichment for users endpoints
callmekatootie Oct 13, 2020
92af080
Merge branch 'develop' of github.com:topcoder-platform/u-bahn-api int…
callmekatootie Oct 13, 2020
365423a
Support filtering by external id on users
callmekatootie Oct 13, 2020
95eb66b
Support filtering by org id on users
callmekatootie Oct 13, 2020
211f395
Merge winning submission from enrich contest
callmekatootie Oct 20, 2020
25ea241
Working data insertion script
callmekatootie Oct 21, 2020
7f7a6cb
Working db dump script and misc
callmekatootie Oct 21, 2020
8ac769b
Restore deleted code
callmekatootie Oct 21, 2020
2bf09e4
Merge pull request #54 from topcoder-platform/enrich-2
callmekatootie Oct 21, 2020
310adc9
1. Set the enrich policy name as a config
callmekatootie Oct 22, 2020
07ea1ad
Merge pull request #56 from topcoder-platform/enrich
callmekatootie Oct 22, 2020
2f5269e
Update elasticsearch host to support elastic cloud since we are using…
callmekatootie Oct 22, 2020
3006252
touch
cwdcwd Oct 22, 2020
e76171c
Debug why db to es migration script failed
callmekatootie Oct 23, 2020
f58967f
Merge branch 'develop' of github.com:topcoder-platform/u-bahn-api int…
callmekatootie Oct 23, 2020
49aa2fb
more debugging
callmekatootie Oct 23, 2020
354fedf
Fix issue where data migration from db to es fails
callmekatootie Oct 23, 2020
6235c7f
Fix issue where data migration from db to es fails
callmekatootie Oct 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update elasticsearch host to support elastic cloud since we are using…
… enrich feature, which is unsupported by AWS ES
  • Loading branch information
callmekatootie committed Oct 22, 2020
commit 2f5269eee381249b5b3097b32a7a014f12da56c0
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Configuration for the application is at config/default.js and config/production.
- UBAHN_UPDATE_TOPIC: Kafka topic for update message
- UBAHN_DELETE_TOPIC: Kafka topic for delete message
- UBAHN_AGGREGATE_TOPIC: Kafka topic that is used to combine all create, update and delete message(s)
- ES.HOST: Elasticsearch host
- ES_HOST: Elasticsearch host
- ES.DOCUMENTS: Elasticsearch index, type and id mapping for resources.
- ATTRIBUTE_GROUP_PIPELINE_ID: The pipeline id for enrichment with attribute group. Default is `attributegroup-pipeline`
- SKILL_PROVIDER_PIPELINE_ID: The pipeline id for enrichment with skill provider. Default is `skillprovider-pipeline`
Expand All @@ -46,6 +46,9 @@ Configuration for the application is at config/default.js and config/production.
- ACHIEVEMENT_PROVIDER_ENRICH_POLICYNAME: The enrich policy for achievement provider. Default is `achievementprovider-policy`
- SKILL_ENRICH_POLICYNAME: The enrich policy for skill. Default is `skill-policy`
- ATTRIBUTE_ENRICH_POLICYNAME: The enrich policy for skill. Default is `attribute-policy`
- ELASTICCLOUD_ID: The elastic cloud id, if your elasticsearch instance is hosted on elastic cloud. DO NOT provide a value for ES_HOST if you are using this
- ELASTICCLOUD_USERNAME: The elastic cloud username for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
- ELASTICCLOUD_PASSWORD: The elastic cloud password for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud

For `ES.DOCUMENTS` configuration, you will find multiple other configurations below it. Each has default values that you can override using the environment variables

Expand Down
7 changes: 7 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ module.exports = {
// ElasticSearch
ES: {
HOST: process.env.ES_HOST || 'http://localhost:9200',

ELASTICCLOUD: {
id: process.env.ELASTICCLOUD_ID,
username: process.env.ELASTICCLOUD_USERNAME,
password: process.env.ELASTICCLOUD_PASSWORD
},

// es mapping: _index, _type, _id
DOCUMENTS: {
achievementprovider: {
Expand Down
8 changes: 0 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@hapi/joi": "^16.1.8",
"@hapi/joi-date": "^2.0.1",
"amazon-qldb-driver-nodejs": "^0.1.1-preview.2",
"aws-elasticsearch-connector": "^9.0.0",
"aws-sdk": "^2.627.0",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
Expand Down
15 changes: 10 additions & 5 deletions src/common/es-client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const config = require('config')
const AWS = require('aws-sdk')
const elasticsearch = require('@elastic/elasticsearch')
const createAwsElasticsearchConnector = require('aws-elasticsearch-connector')

AWS.config.region = config.AWS_REGION

Expand All @@ -17,12 +16,18 @@ function getESClient () {
return esClient
}
const host = config.ES.HOST
const cloudId = config.ES.ELASTICCLOUD.id
if (!esClient) {
// AWS ES configuration is different from other providers
if (/.*amazonaws.*/.test(host)) {
if (cloudId) {
// Elastic Cloud configuration
esClient = new elasticsearch.Client({
...createAwsElasticsearchConnector(AWS.config),
node: host
cloud: {
id: cloudId
},
auth: {
username: config.ES.ELASTICCLOUD.username,
password: config.ES.ELASTICCLOUD.password
}
})
} else {
esClient = new elasticsearch.Client({
Expand Down