Skip to content

Move QueryBuilders to Core

Description:

ADR: #154 (closed)

The Search service contains duplicated code for constructing Elasticsearch queries within CSP modules, in classes such as QueryBase.java and QueryServiceImpl.java. These redundancies add complexity to code maintenance without offering visible benefits. Query builders do not have CSP-specific code.

Differences have emerged in these classes over time, most notable that was affected during refactoring:

  • Azure DependencyLogger was refactored, and to the Search core was added an Interface to abstract this logger, with the default implementation.
  • The AWS QueryBuilder involves mandatory ID prefix injection into the query, which appears contradictory to the Search API that limits results. The injection of the ID prefix was not moved to the Core Query Builder:
    queryBuilder.must(prefixQuery("id", String.format("%s:", this.dpsHeaders.getPartitionId())));
    In the Elastisearch request, it looked like this:
					"bool": {
						"must": [
							{
								"prefix": {
									"id": {
										"value": "opendes:",
										"boost": 1.0
									}
								}
							}
						],

How to test:

Integration tests.

Changes include:

  • Refactor (a non-breaking change that improves code maintainability).
  • Bugfix (a non-breaking change that solves an issue).
  • New feature (a non-breaking change that adds functionality).
  • Breaking change (a change that is not backward-compatible and/or changes current functionality).

Changes in:

  • GC
  • Azure
  • AWS
  • IBM

Dev Checklist:

  • Added Unit Tests, wherever applicable.
  • Updated the Readme, if applicable.
  • Existing Tests pass
  • Verified functionality locally
  • Self Reviewed my code for formatting and complex business logic.

Other comments:

It is possible to roll back CSP migration if the agreement isn't met. The QueryBuilder in Search Core would then become optional, and CSP could continue using their own QueryBuilder.

Edited by Rustam Lotsmanenko (EPAM)

Merge request reports

Loading