Skip to content

Commit

Permalink
fix testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
deepgarg-visa committed Feb 8, 2025
1 parent bf1faaa commit 6d50d30
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,8 @@ private static Map<String, Object> getMappingsForField(
.ifPresent(
fieldName -> mappings.put(fieldName, ImmutableMap.of(TYPE, ESUtils.LONG_FIELD_TYPE)));

final String fieldName = searchableFieldSpec.getSearchableAnnotation().getFieldName();
if (searchableFieldSpec.getSearchableAnnotation().isIncludeSystemModifiedAt()) {
String modifiedAtFieldName =
searchableFieldSpec
.getSearchableAnnotation()
.getSystemModifiedAtFieldName()
.orElse(String.format("%sSystemModifiedAt", fieldName));
if (ESUtils.getSystemModifiedAtFieldName(searchableFieldSpec).isPresent()) {
String modifiedAtFieldName = ESUtils.getSystemModifiedAtFieldName(searchableFieldSpec).get();
mappings.put(modifiedAtFieldName, ImmutableMap.of(TYPE, ESUtils.DATE_FIELD_TYPE));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.linkedin.metadata.models.annotation.SearchableAnnotation.FieldType;
import com.linkedin.metadata.models.extractor.FieldExtractor;
import com.linkedin.metadata.models.registry.EntityRegistry;
import com.linkedin.metadata.search.utils.ESUtils;
import com.linkedin.r2.RemoteInvocationException;
import com.linkedin.structured.StructuredProperties;
import com.linkedin.structured.StructuredPropertyDefinition;
Expand Down Expand Up @@ -255,12 +256,8 @@ public void setSearchableValue(
return;
}

if (fieldSpec.getSearchableAnnotation().isIncludeSystemModifiedAt()) {
String modifiedAtFieldName =
fieldSpec
.getSearchableAnnotation()
.getSystemModifiedAtFieldName()
.orElse(String.format("%sSystemModifiedAt", fieldName));
if (ESUtils.getSystemModifiedAtFieldName(fieldSpec).isPresent()) {
String modifiedAtFieldName = ESUtils.getSystemModifiedAtFieldName(fieldSpec).get();
searchDocument.set(

Check warning on line 261 in metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java

View check run for this annotation

Codecov / codecov/patch

metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java#L260-L261

Added lines #L260 - L261 were not covered by tests
modifiedAtFieldName,
JsonNodeFactory.instance.numberNode((Long) System.currentTimeMillis()));

Check warning on line 263 in metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java

View check run for this annotation

Codecov / codecov/patch

metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java#L263

Added line #L263 was not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,4 +907,15 @@ public static BoolQueryBuilder buildFilterNonLatestEntities(
queryFilterRewriteChain);
return QueryBuilders.boolQuery().should(isLatest).should(isNotVersioned).minimumShouldMatch(1);
}

public static Optional<String> getSystemModifiedAtFieldName(
@Nonnull SearchableFieldSpec searchableFieldSpec) {
final String fieldName = searchableFieldSpec.getSearchableAnnotation().getFieldName();
return searchableFieldSpec.getSearchableAnnotation().isIncludeSystemModifiedAt()
? searchableFieldSpec
.getSearchableAnnotation()
.getSystemModifiedAtFieldName()
.or(() -> Optional.of(String.format("%sSystemModifiedAt", fieldName)))
: Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ public void testGetDefaultAggregationsHasFields() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchConfiguration config = new SearchConfiguration();
config.setMaxTermBucketSize(25);
Expand Down Expand Up @@ -203,7 +205,9 @@ public void testGetDefaultAggregationsFields() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchConfiguration config = new SearchConfiguration();
config.setMaxTermBucketSize(25);
Expand Down Expand Up @@ -235,7 +239,9 @@ public void testGetSpecificAggregationsHasFields() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchableAnnotation annotation2 =
new SearchableAnnotation(
Expand All @@ -252,7 +258,9 @@ public void testGetSpecificAggregationsHasFields() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchConfiguration config = new SearchConfiguration();
config.setMaxTermBucketSize(25);
Expand Down Expand Up @@ -462,7 +470,9 @@ public void testAggregateOverFieldsAndStructProp() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchableAnnotation annotation2 =
new SearchableAnnotation(
Expand All @@ -479,7 +489,9 @@ public void testAggregateOverFieldsAndStructProp() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchConfiguration config = new SearchConfiguration();
config.setMaxTermBucketSize(25);
Expand Down Expand Up @@ -532,7 +544,9 @@ public void testAggregateOverFieldsAndStructPropV1() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchableAnnotation annotation2 =
new SearchableAnnotation(
Expand All @@ -549,7 +563,9 @@ public void testAggregateOverFieldsAndStructPropV1() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
false);
false,
false,
Optional.empty());

SearchConfiguration config = new SearchConfiguration();
config.setMaxTermBucketSize(25);
Expand Down Expand Up @@ -606,7 +622,9 @@ public void testMissingAggregation() {
Optional.empty(),
Collections.emptyMap(),
Collections.emptyList(),
true);
true,
false,
Optional.empty());

SearchConfiguration config = new SearchConfiguration();
config.setMaxTermBucketSize(25);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ public void testGetStandardFields() {
Optional.empty(),
Map.of(),
List.of(),
false),
false,
false,
Optional.empty()),
mock(DataSchema.class)),
new SearchableFieldSpec(
mock(PathSpec.class),
Expand All @@ -472,7 +474,9 @@ public void testGetStandardFields() {
Optional.empty(),
Map.of(),
List.of(),
false),
false,
false,
Optional.empty()),
mock(DataSchema.class)),
new SearchableFieldSpec(
mock(PathSpec.class),
Expand All @@ -490,7 +494,9 @@ public void testGetStandardFields() {
Optional.empty(),
Map.of(),
List.of(),
false),
false,
false,
Optional.empty()),
mock(DataSchema.class))));

fieldConfigs =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ record BusinessAttributeAssociation {
*/
@Searchable = {
"fieldName": "schemaFieldBusinessAttribute",
"queryByDefault": false,
"includeSystemModifiedAt": true,
"systemModifiedAtFieldName": "schemaFieldBusinessAttributeModifiedAt"
}
Expand Down

0 comments on commit 6d50d30

Please sign in to comment.