Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1029 delete specific indexes contribution collection #1032

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Arrange environment variables and data deletion endpoint into single row in capability. [#989](https://github.com/rokwire/rokwire-building-blocks-api/issues/989)
- API Doc Dockerfile URLs to include new building blocks and remove unsupported building blocks. [#831](https://github.com/rokwire/rokwire-building-blocks-api/issues/831)
- Talent fields yaml configuration [#949](https://github.com/rokwire/rokwire-building-blocks-api/issues/949)
- Drop old indexes in contributions collection in mongodb. [#1029](https://github.com/rokwire/rokwire-building-blocks-api/issues/1029)

### Fixed
- Fix Core BB service token support in events [#994](https://github.com/rokwire/rokwire-building-blocks-api/issues/994)
Expand Down
4 changes: 2 additions & 2 deletions contributions/api/utils/mongoutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
coll_contribution = db_contribution[cfg.CONTRIBUTION_COLL_NAME] # set contribution collection
# drop old indexes in contribution collection
coll_contribution_indexes = coll_contribution.index_information().keys()
# get all indexes except id and text index
coll_contribution_old_indexes = [index for index in coll_contribution_indexes if index not in ['_id_', 'text_index']]
# get old indexes
coll_contribution_old_indexes = [index for index in coll_contribution_indexes if index in ['name', 'capabilities.name', 'talents.name']]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested using Robo 3T that the name index is getting removed. Thanks.

In the future, as part of code cleanup, I think these lines of code could be converted to an init_db function called when the extractor starts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue created

for index_name in coll_contribution_old_indexes:
coll_contribution.drop_index(index_name)
# create compound text indexes with equal weightage
Expand Down