tihom88 commented on code in PR #2270: URL: https://github.com/apache/jackrabbit-oak/pull/2270#discussion_r2079477093
########## oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java: ########## @@ -97,9 +107,48 @@ private static ObjectBuilder<TypeMapping> loadMappings(@NotNull TypeMapping.Buil if (indexDefinition.inferenceDefinition != null) { mapInferenceDefinition(builder, indexDefinition.inferenceDefinition); } + // We only add mappings if both the inference config (in queryEngineSettings config) and the inference index config are enabled. + if (InferenceConfig.getInstance().isInferenceEnabled() && InferenceConfig.getInstance().isEnabled()) { + mapInferenceConfig(builder, indexDefinition, InferenceConfig.getInstance()); + } return builder; } + private static void mapInferenceConfig(TypeMapping.Builder builder, @NotNull ElasticIndexDefinition indexDefinition, @NotNull InferenceConfig inferenceConfig) { + String indexName = PathUtils.getName(indexDefinition.getIndexName()); + + InferenceIndexConfig inferenceIndexConfig = inferenceConfig.getInferenceIndexConfig(indexName); + if (InferenceIndexConfig.NOOP.equals(inferenceIndexConfig)) { + return; + } + try { + // We are already validating the enricherConfigJson in the InferenceIndexConfig constructor + Map<String, Object> enricherConfigJson = mapper.readValue(inferenceConfig.getInferenceIndexConfig(indexName).getEnricherConfig(), + new TypeReference<Map<String, Object>>() { + }); + // Store the enricher configuration in the index metadata so that it can be used by the enricher service + enricherConfigJson.forEach((k, v) -> { + builder.meta(k, JsonData.of(v)); + }); + } catch (JsonProcessingException e) { + throw new RuntimeException("enricherConfig parsing should never fail as it is validated in InferenceIndexConfig" + e.getMessage()); + } + Review Comment: Enricher is already configurable and is a json string. Added a TODO under this for making mappings configurable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org