Skip to content

Search: allow to search on different versions of subprojects #7634

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

Merged
merged 7 commits into from
Nov 19, 2020

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Nov 2, 2020

Put this under a feature flag because who knows if this is going to explode in production :D

So, with filters you can't aggregate them to say "I want results from documents that match both, this version and project", so I had to use a bool query that represents this.

For projects where subprojects that don't match the same version as the parent project this will do an extra query (this may be not bad, I hope), we could fetch both in one query with an or, but then the logic would be a little more complex I think, but we can try that if this is slow.

Also, if the search query is slow, we can try some things:

  • Use filters if all the subrprojects share the same version (we will use the new method if there is a project that needs to query the default version)
  • When a subproject needs to match a different version, we can query all versions that share the same version in one query (using filters) and in another query using the projects method, and then merge the results (here I'm not sure if the score would be correct).

Note: all other tests without the feature flag are also passing when I activated this feature by default, so the order of the results are the same as using the filters

Based on #7633

@stsewd stsewd added Needed: tests Tests are required PR: work in progress Pull request is not ready for full review labels Nov 2, 2020
@stsewd stsewd marked this pull request as draft November 2, 2020 22:54
@stsewd stsewd force-pushed the search-subprojects branch 2 times, most recently from 074a6f0 to a5cb8ac Compare November 3, 2020 14:20
Mainly this was done to allow us support searching on
different versions of subprojects.
Currently, we assume we search the same version for all subprojects.

- _get_all_projects_data and _get_all_projects
  were merged into just one method.
  And instead of returning a list of projects we return a dictionary of project slugs mapped to a VersionData object.
- There is some duplication in .com.
  `_has_permission` and `_get_subproject_versions_queryset`
  are overridden in .com.
- ProjectData was renamed to VersionData since it has more attributes
  related to a version than a project.
@stsewd stsewd force-pushed the refactor-search-view branch from f3590d6 to 9cacb2c Compare November 3, 2020 14:26
Mainly this was done to allow us support searching on
different versions of subprojects.
Currently, we assume we search the same version for all subprojects.

- _get_all_projects_data and _get_all_projects
  were merged into just one method.
  And instead of returning a list of projects we return a dictionary of project slugs mapped to a VersionData object.
- There is some duplication in .com.
  `_has_permission` and `_get_subproject_versions_queryset`
  are overridden in .com.
- ProjectData was renamed to VersionData since it has more attributes
  related to a version than a project.
@stsewd stsewd force-pushed the search-subprojects branch from a5cb8ac to 90accc5 Compare November 3, 2020 14:54
@stsewd stsewd force-pushed the search-subprojects branch from 90accc5 to c908174 Compare November 3, 2020 15:16
Mainly this was done to allow us support searching on
different versions of subprojects.
Currently, we assume we search the same version for all subprojects.

- _get_all_projects_data and _get_all_projects
  were merged into just one method.
  And instead of returning a list of projects we return a dictionary of project slugs mapped to a VersionData object.
- There is some duplication in .com.
  `_has_permission` and `_get_subproject_versions_queryset`
  are overridden in .com.
- ProjectData was renamed to VersionData since it has more attributes
  related to a version than a project.
@stsewd stsewd force-pushed the refactor-search-view branch from 9cacb2c to e5c0337 Compare November 3, 2020 17:10
@stsewd stsewd removed Needed: tests Tests are required PR: work in progress Pull request is not ready for full review labels Nov 3, 2020
@stsewd stsewd force-pushed the search-subprojects branch from 985793d to 628edad Compare November 3, 2020 19:26
@stsewd stsewd marked this pull request as ready for review November 3, 2020 19:26
@stsewd stsewd requested a review from a team November 3, 2020 20:56
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Solid improvement. The search logic is getting really complex, I wish I knew how to simplify it :/

)
for project, version in self.projects.items()
]
bool_query = Bool(must=[bool_query, Bool(should=versions_query)])
Copy link
Member

Choose a reason for hiding this comment

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

I"m a little worried about this as you noted, but lets see how it performs in prod.

Base automatically changed from refactor-search-view to master November 19, 2020 18:47
@stsewd stsewd merged commit 5234f41 into master Nov 19, 2020
@stsewd stsewd deleted the search-subprojects branch November 19, 2020 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants