Skip to content
Snippets Groups Projects
Commit 11a5284e authored by Zhibin Mai's avatar Zhibin Mai
Browse files

do get, then check instead of check, then get when using cache

parent f173816d
No related branches found
No related tags found
4 merge requests!545Draft: add env variables,!543Draft: az/sa-support-index-extended-properties,!540Draft: support index extended properties,!465Index extended properties defined in property configurations
Pipeline #171462 failed
......@@ -151,15 +151,13 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
} else {
List<SearchRecord> childrenRecords = searchChildrenRecords(relatedObjectsSpec.getRelatedObjectKind(), relatedObjectsSpec.getRelatedObjectID(), objectId);
for (SearchRecord record : childrenRecords) {
Map<String, Object> childDataMap;
// If the child record is in the cache, that means the record was updated very recently.
// The search result from elasticsearch may not be the latest version.
if(this.relatedObjectCache.get(record.getId()) != null) {
childDataMap = this.relatedObjectCache.get(record.getId());
}
else {
// In this case, use the cache's record instead of the record from search result
Map<String, Object> childDataMap = this.relatedObjectCache.get(record.getId());
if(childDataMap == null) {
childDataMap = record.getData();
}
Map<String, Object> propertyValues = getPropertyValues(childDataMap, path.getValueExtraction(), configuration.isExtractFirstMatch());
propertyValues = PropertyUtil.replacePropertyPaths(configuration.getName(), path.getValueExtraction().getValuePath(), propertyValues);
if (allPropertyValues.isEmpty() && configuration.isExtractFirstMatch()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment