From 38f9d3a9d78fb23ae197d6fc0e1cf1594074f1e2 Mon Sep 17 00:00:00 2001 From: MZhu9 <ujr7dj3ljx3fpstxflyytui5kziqgnbscv3po6mrm3ikbn52frqq> Date: Thu, 5 Jan 2023 14:30:40 -0600 Subject: [PATCH] index normalizedKind attribute under tags for all records --- .../osdu/indexer/service/IndexerServiceImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java index dd3d7519c..31e253eae 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java @@ -70,6 +70,9 @@ public class IndexerServiceImpl implements IndexerService { private final Gson gson = new GsonBuilder().serializeNulls().create(); + // we index a normalized kind (authority + source + entity type + major version) as a tags attribute for all records + private static String NORMALIZATION_KIND_TAG_ATTRIBUTE_NAME = "normalizedKind"; + @Inject private JaxRsDpsLog jaxRsDpsLog; @Inject @@ -310,6 +313,7 @@ public class IndexerServiceImpl implements IndexerService { String authority = kindParts[0]; String source = kindParts[1]; String type = kindParts[2]; + String[] versionParts = kindParts[3].split("\\."); document.setKind(storageRecord.getKind()); document.setNamespace(authority + ":" + source); document.setAuthority(authority); @@ -319,9 +323,12 @@ public class IndexerServiceImpl implements IndexerService { document.setVersion(storageRecord.getVersion()); document.setAcl(storageRecord.getAcl()); document.setLegal(storageRecord.getLegal()); - if (storageRecord.getTags() != null) { - document.setTags(storageRecord.getTags()); + if (storageRecord.getTags() == null) { + Map<String, String> constantTags = new HashMap<>(); + constantTags.put(IndexerServiceImpl.NORMALIZATION_KIND_TAG_ATTRIBUTE_NAME, String.format("%s:%s:%s:%s", authority, source, type, versionParts[0])); + storageRecord.setTags(constantTags); } + document.setTags(storageRecord.getTags()); document.setCreateUser(storageRecord.getCreateUser()); document.setCreateTime(storageRecord.getCreateTime()); if (!Strings.isNullOrEmpty(storageRecord.getModifyUser())) { -- GitLab