Skip to content

Commit

Permalink
Add primary_genre to avoid duplication of podcasts across category sh…
Browse files Browse the repository at this point in the history
…owcases
  • Loading branch information
eemp committed Mar 2, 2019
1 parent 3d34293 commit 85d9a1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/podcasts-fetcher/etc/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@
"popularity": {
"type": "long"
},
"primary_genre": {
"type": "object",
"properties": {
"id": {
"type": "keyword",
"ignore_above": 256
},
"name": {
"type": "keyword",
"ignore_above": 256
}
}
},
"release_date": {
"type": "date"
}
Expand Down
4 changes: 4 additions & 0 deletions packages/podcasts-fetcher/index-itunes-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function getRecordFromResult(scanOffset, result, idx) {
id: result.trackId,
name: result.trackName,
popularity: scanOffset + idx,
primary_genre: {
id: _.get(result, 'genreIds[0]'),
name: _.get(result, 'genres[0]',
},
release_date: result.releaseDate,
type: PODCAST_MEDIA,
};
Expand Down
1 change: 1 addition & 0 deletions packages/podcasts-fetcher/scripts/reindex-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
[ -z "$ES_INDEX" ] && echo "Need to set ENV.ES_INDEX" && exit 1

curl -XPOST $ES_SERVER/$ES_INDEX/podcast/_update_by_query?conflicts=proceed -H 'Content-Type: application/json' -d '{ "query": { "match_all": {} } }'
#curl -XPOST $ES_SERVER/$ES_INDEX/podcast/_update_by_query?conflicts=proceed -H 'Content-Type: application/json' -d '{ "query": { "match_all": {} }, "script": { "source": "ctx._source['"'"'primary_genre'"'"'] = ctx._source['"'"'genres'"'"'][0]" } }'

0 comments on commit 85d9a1a

Please sign in to comment.