-
Notifications
You must be signed in to change notification settings - Fork 230
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
#1521: Configure which fields are indexed in the Ditto search index per namespace pattern #1870
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @an1310 for that awesome PR.
Looking already really good - I did a quick round of comments to what I found.
What is still missing before getting merged:
- an "empty" default configuration in the
search.conf
file- containing e.g. commented out example of how the config for a concrete namespace would look like
- documentation on how to enable the
SearchIndexingSignalEnrichmentFacadeProvider
, maybe both:- in
search.conf
as commented out alternative to the defaultDittoCachingSignalEnrichmentFacadeProvider
forditto.extensions.caching-signal-enrichment-facade-provider
- and as a subsection in the Operating Ditto docs
- Next to Restricting entity creation
- Source is here: installation-operating.md
- Similar description as for the "Restricting entity creation"
- in
And one optional wish from me 😁
I just figured out that the entity-creation
configuration already supports adding wildcards.
So maybe we could integrate that in the same way, see:
Lines 37 to 55 in 2a35c6f
private DefaultCreationRestrictionConfig(final ConfigWithFallback configWithFallback) { | |
this.resourceTypes = Set.copyOf(configWithFallback.getStringList( | |
CreationRestrictionConfigValues.RESOURCE_TYPES.getConfigPath() | |
)); | |
this.namespacePatterns = compile(List.copyOf(configWithFallback.getStringList( | |
CreationRestrictionConfigValues.NAMESPACES.getConfigPath()) | |
)); | |
this.authSubjectPatterns = compile(List.copyOf(configWithFallback.getStringList( | |
CreationRestrictionConfigValues.AUTH_SUBJECTS.getConfigPath()) | |
)); | |
} | |
private static List<Pattern> compile(final List<String> patterns) { | |
return patterns.stream() | |
.map(LikeHelper::convertToRegexSyntax) | |
.filter(Objects::nonNull) | |
.map(Pattern::compile) | |
.toList(); | |
} |
So basically the getNamespace
would return a Pattern
instead which is created during the config parsing.
An additional benefit of that would be that is configured commonly as the "Restriction entity creation".
What do you think about that?
...org/eclipse/ditto/internal/models/signalenrichment/SearchIndexingSignalEnrichmentFacade.java
Outdated
Show resolved
Hide resolved
...org/eclipse/ditto/internal/models/signalenrichment/SearchIndexingSignalEnrichmentFacade.java
Outdated
Show resolved
Hide resolved
...org/eclipse/ditto/internal/models/signalenrichment/SearchIndexingSignalEnrichmentFacade.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/eclipse/ditto/internal/models/signalenrichment/SignalEnrichmentCacheKey.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/eclipse/ditto/internal/models/signalenrichment/SignalEnrichmentCacheKey.java
Outdated
Show resolved
Hide resolved
...search/service/persistence/write/streaming/SearchIndexingSignalEnrichmentFacadeProvider.java
Outdated
Show resolved
Hide resolved
...search/service/persistence/write/streaming/SearchIndexingSignalEnrichmentFacadeProvider.java
Outdated
Show resolved
Hide resolved
...search/service/persistence/write/streaming/SearchIndexingSignalEnrichmentFacadeProvider.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/eclipse/ditto/thingsearch/service/starter/config/DittoSearchConfigTest.java
Outdated
Show resolved
Hide resolved
...g/eclipse/ditto/thingsearch/service/common/config/DefaultNamespaceSearchIndexConfigTest.java
Outdated
Show resolved
Hide resolved
...a/org/eclipse/ditto/thingsearch/service/common/config/DefaultNamespaceSearchIndexConfig.java
Outdated
Show resolved
Hide resolved
...a/org/eclipse/ditto/thingsearch/service/common/config/DefaultNamespaceSearchIndexConfig.java
Outdated
Show resolved
Hide resolved
...a/org/eclipse/ditto/thingsearch/service/common/config/DefaultNamespaceSearchIndexConfig.java
Outdated
Show resolved
Hide resolved
Feature wise it works really great 👍 |
I think this suggestion is great. If it's okay, can we do this in a separate issue and I can contribute it? |
I would like to add it to 3.5.0 still - Because otherwise it would again take ~3 months for the next minor release of Ditto. Then it would not really matter if new issue and PR or use this one .. |
One TODO to check (I can also check - but maybe you are quicker):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@an1310 I did a review commit, hope you don't mind - providing:
- added a cache to SearchIndexingSignalEnrichmentFacade in order to only evaluate "patterns" once for a given namespace
- removed copy&pasted unit tests in SearchIndexingSignalEnrichmentFacadeTest by adding another abstract test class AbstractCachingSignalEnrichmentFacadeTest
- added a unit test testing selection of JsonFieldSelectors based on different namespaces
- minor cleanup and formatting
- enhanced documentation about how to configure the indexed namespaces via system properties
For me, this would now good to be merged 👍
I don't mind in the slightest. Glad to have helped. |
* added a cache to SearchIndexingSignalEnrichmentFacade in order to only evaluate "patterns" once for a given namespace * removed copy&pasted unit tests in SearchIndexingSignalEnrichmentFacadeTest by adding another abstract test class AbstractCachingSignalEnrichmentFacadeTest * added a unit test testing selection of JsonFieldSelectors based on different namespaces * minor cleanup and formatting * enhanced documentation about how to configure the indexed namespaces via system properties Signed-off-by: Thomas Jäckle <[email protected]>
* consolidated config keys to be more intuitive Signed-off-by: Thomas Jäckle <[email protected]>
@an1310 I also just provided configuration via the Helm chart - so that it is easily enabled and configured via Once the build is green (nowadays GitLab runners seem quite busy), I will merge :) Thanks a lot for this contribution - I guess not only you will benefit from that configuration. |
Long time coming.
Resolves: #1521