Backend: Support Ability to Un-Nest Knowledge Center Pages (#20096)

* Backend: Support Ability to Un-Nest Knowledge Center Pages

* fix build

---------

Co-authored-by: Ashish Gupta <ashish@getcollate.io>
This commit is contained in:
sonika-shah 2025-04-30 10:31:54 +05:30 committed by GitHub
parent 970f6fbc0b
commit 16997110e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -582,11 +582,19 @@ public class SearchRepository {
if (field.getName().contains(PARENT)) {
EntityReference entityReferenceBeforeUpdate =
JsonUtils.readValue(field.getOldValue().toString(), EntityReference.class);
// Remove the parent field from the entity in search
String parentFieldPath = "parent";
Map<String, Object> params = new HashMap<>();
params.put("field", parentFieldPath);
searchClient.updateEntity(
indexName, entity.getId().toString(), params, "ctx._source.remove(params.field)");
// Propagate FQN updates to all subchildren
String originalFqn =
FullyQualifiedName.add(
entityReferenceBeforeUpdate.getFullyQualifiedName(), entity.getName());
searchClient.updateByFqnPrefix(indexName, originalFqn, "", FIELD_FULLY_QUALIFIED_NAME);
searchClient.updateByFqnPrefix(
indexName, originalFqn, entity.getName(), FIELD_FULLY_QUALIFIED_NAME);
}
}
} else if (changeDescription != null