Details
-
Bug
-
Resolution: Unresolved
-
Neutral
-
None
-
1.0.0
-
None
-
Java 11, Magnolia 6.2.15
Description
The Index Editor app does not require to add a linkGeneratorClass. However, if it is missing the index creation fails with a NullPointerException in IndexJcrDataFactory.
Workaround:
Patch IndexJcrDataFactory.addLinkFields(...) and add null check
protected static void addLinkFields(GeneratedIndexPackage indexPackage, Node node, IndexItemConfiguration index, MappingItemConfiguration mappingField) throws ElasticConfigurationException { if (index.getLinkGeneratorClass() != null) { IndexFieldsLinkGenerator<?> linkGenerator = Components.getComponent(index.getLinkGeneratorClass()); if (linkGenerator instanceof JcrIndexFieldsLinkGenerator) { JcrIndexFieldsLinkGenerator<Node> jcrLinkGenerator = (JcrIndexFieldsLinkGenerator<Node>) linkGenerator; Map<String, String> linkMap = jcrLinkGenerator.getLinks(node); for (String linkFieldName : linkMap.keySet()) { String link = linkMap.get(linkFieldName); ElasticItem elasticItemManually; try { elasticItemManually = new ElasticItem(TypeSpecification.TEXT, linkFieldName, node.getPath(), node.getIdentifier()); elasticItemManually.setValue(link); indexPackage.getIndexPackage().put(elasticItemManually.getName(), elasticItemManually); indexPackage.setItemsAdded(true); } catch (RepositoryException e) { throw new ElasticConfigurationException("query-manager.elastic-index-app.error.unable_read_node", e, log); } } } } }
Checklists
Acceptance criteria