F1 (Java) Story 28 [Search]: Implement search in a namespace context
Description
Today's Search logic is namespace-aware. It doesn't respect the x-collaboration header and can't perform a search in a custom namespace. We need to implement an accordant logic for it.
See ADR - Project & Workflow Services - Core Services Integration - Search Service Support
Acceptance criteria
- when the x-collaboration header is set, the search happens in a custom NS
Testing scenarios
- all unit tests
- search with and without the set x-collaboration header. Make sure the results are properly different.
Technical notes
Search Query Builder
- Validate the
x-collaboration
header similarly as in the Storage service. We do not need to validate its existence as Elasticsearch will return empty results if there are no records with givenx-collaboration
and that's expected behavior. - Update existing query builder here https://community.opengroup.org/osdu/platform/system/search-service/-/blob/master/search-core/src/main/java/org/opengroup/osdu/search/provider/impl/CoreQueryBase.java?ref_type=heads#L131.
- Add
exists
queries to it with thex-collaboration
property in it,exists
queries should be wrapped inmust
ormust not
. - If we're searching within a custom namespace then we need to use
must(exist)
ANDmust(x-collaboration==<collaboration id value from headers>)
- If we're searching in SOR then we need to use a single
mustNot(exist)
.mustNot(exist)
should always accompany queries running in SOR if the feature is enabled. - New functionality should be controlled via a feature flag.
- New functionality should be tested with unit tests.
- Update documentation, and provide examples of how new functionality works. https://community.opengroup.org/osdu/platform/system/search-service/-/tree/master/docs/docs
queryBuilder.must(new ExistsQueryBuilder());
queryBuilder.mustNot(new ExistsQueryBuilder());
Integration tests
- When searching in SOR I should not find records from a custom namespace.
- When searching in custom namespace I should not find records from SOR.
- I should not find a record existing only in SOR when searching in a custom namespace.
- I should be able to find different records with the same ID in SOR and a custom namespace.
- New test cases should be controlled via cucumber tags, for example : https://community.opengroup.org/osdu/platform/system/search-service/-/blob/master/testing/integration-tests/search-test-core/src/main/resources/features/query/singlecluster/Query.feature#L269
Edited by Rustam Lotsmanenko (EPAM)