Skip to content

Commit

Permalink
Merge pull request #324 from publichealthengland/master
Browse files Browse the repository at this point in the history
Bringing develop up to date
  • Loading branch information
openbook authored Aug 13, 2021
2 parents 724343f + 09eec0f commit 7aa67d9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/server/api/v1/apisearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ const buildMatchQuery = (searchTerm, fuzzy, page, pageSize) => {
}

const buildPrefixQuery = (searchTerm, page, pageSize) => {
let fields = ['name.completion^10']
let fields = ['name', 'name.completion^10']

if (searchTerm.length > 2) {
fields.push(
'realName',
'realName.completion',
'title',
'title.completion',
'relatedDrugs.drugName.completion',
'relatedDrugs.synonyms.completion',
Expand Down
10 changes: 10 additions & 0 deletions app/server/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ if (
})
}

if (
config.elasticsearch.basicAuth &&
config.elasticsearch.basicAuth.username
) {
elasticSearchConf.auth = {
username: config.elasticsearch.basicAuth.username,
password: config.elasticsearch.basicAuth.password
}
}

const search = new Client(elasticSearchConf)

var store
Expand Down
4 changes: 3 additions & 1 deletion app/shared/components/AccessibleSearch/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ export default class AccessibleSearch extends React.Component {
if (drug._source.title) {
return `<span data-type='news' data-slug='${drug._source.slug}'>${drug._source.title}</span>`
/*eslint-disable */
} else if (drug._source.name != drug._source.realName) {
} else if (drug._source.realName && drug._source.name !== drug._source.realName) {
/*eslint-enable */
return `<span data-type='drug' data-slug='${drug._source.slug}' class='autocomplete__option--background'>${drug._source.name}</span> <span>(${drug._source.realName})</span>`
} else if (!drug._source.realName) {
return `<span data-type='drug' data-slug='${drug._source.slug}' class='autocomplete__option--background'>${drug._source.name}</span>`
}
return `<span data-type='drug' data-slug='${drug._source.slug}' class='autocomplete__option--background'>${drug._source.realName}</span>`
})
Expand Down
4 changes: 3 additions & 1 deletion config.preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ api: https://preview.talktofrank.com
robotsDisallow: true

elasticsearch:
host: ''
basicAuth:
username: 'ttf-es-master'
password: !!import/single '../config.elasticsearch.password.yaml'

contentful:
contentHost: 'preview.contentful.com'
Expand Down
5 changes: 5 additions & 0 deletions config.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ contentful:
contentAccessToken: !!import/single '../config.creds.yaml'
webhookSecretKey: !!import/single '../config.webhooksecretkey.yaml'

elasticsearch:
basicAuth:
username: 'ttf-es-master'
password: !!import/single '../config.elasticsearch.password.yaml'

robotsDisallow: false

sentry:
Expand Down
3 changes: 1 addition & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ canonicalHost: https://www.talktofrank.com
robotsDisallow: true

elasticsearch:
host: "https://vpc-ttf-prod-sbocvb3kw7ykfpq6jcaj2r4kzi.eu-west-2.es.amazonaws.com/"
# host: 'https://search-talktofrank-elastic-beta-tsq3jroogc3kwgtk4s77uab2he.eu-west-2.es.amazonaws.com/'
host: "https://vpc-ttf-prod-v2-rtpivnkf2dom6xuzfp7wuwz7ui.eu-west-2.es.amazonaws.com/"
amazonES:
region: "eu-west-2"

Expand Down

0 comments on commit 7aa67d9

Please sign in to comment.