Skip to content

Commit

Permalink
feat(gms/search): Adding support for DOUBLE Searchable type (#9369)
Browse files Browse the repository at this point in the history
Co-authored-by: si-chakraborty <si.chakraborty@adevinta.com>
  • Loading branch information
siladitya2 and si-chakraborty committed Dec 6, 2023
1 parent c66619c commit 7fb6086
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public enum FieldType {
DATETIME,
OBJECT,
BROWSE_PATH_V2,
WORD_GRAM
WORD_GRAM,
DOUBLE
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void validateTestEntityInfo(final AspectSpec testEntityInfo) {
assertEquals(new TestEntityInfo().schema().getFullName(), testEntityInfo.getPegasusSchema().getFullName());

// Assert on Searchable Fields
assertEquals(testEntityInfo.getSearchableFieldSpecs().size(), 10);
assertEquals(testEntityInfo.getSearchableFieldSpecs().size(), 11);
assertEquals("customProperties", testEntityInfo.getSearchableFieldSpecMap().get(
new PathSpec("customProperties").toString()).getSearchableAnnotation().getFieldName());
assertEquals(SearchableAnnotation.FieldType.KEYWORD, testEntityInfo.getSearchableFieldSpecMap().get(
Expand Down Expand Up @@ -189,6 +189,10 @@ private void validateTestEntityInfo(final AspectSpec testEntityInfo) {
new PathSpec("foreignKey").toString()).getSearchableAnnotation().getFieldName());
assertEquals(true, testEntityInfo.getSearchableFieldSpecMap().get(
new PathSpec("foreignKey").toString()).getSearchableAnnotation().isQueryByDefault());
assertEquals("doubleField", testEntityInfo.getSearchableFieldSpecMap().get(
new PathSpec("doubleField").toString()).getSearchableAnnotation().getFieldName());
assertEquals(SearchableAnnotation.FieldType.DOUBLE, testEntityInfo.getSearchableFieldSpecMap().get(
new PathSpec("doubleField").toString()).getSearchableAnnotation().getFieldType());


// Assert on Relationship Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ private static Map<String, Object> getMappingsForField(@Nonnull final Searchable
mappingForField.put(TYPE, ESUtils.DATE_FIELD_TYPE);
} else if (fieldType == FieldType.OBJECT) {
mappingForField.put(TYPE, ESUtils.OBJECT_FIELD_TYPE);
} else if (fieldType == FieldType.DOUBLE) {
mappingForField.put(TYPE, ESUtils.DOUBLE_FIELD_TYPE);
} else {
log.info("FieldType {} has no mappings implemented", fieldType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void testMappingsBuilder() {
Map<String, Object> result = MappingsBuilder.getMappings(TestEntitySpecBuilder.getSpec());
assertEquals(result.size(), 1);
Map<String, Object> properties = (Map<String, Object>) result.get("properties");
assertEquals(properties.size(), 19);
assertEquals(properties.size(), 20);
assertEquals(properties.get("urn"), ImmutableMap.of("type", "keyword",
"fields",
ImmutableMap.of("delimited",
Expand Down Expand Up @@ -123,5 +123,9 @@ public void testMappingsBuilder() {
assertEquals(feature1.get("type"), "double");
Map<String, Object> feature2 = (Map<String, Object>) properties.get("feature2");
assertEquals(feature2.get("type"), "double");

// DOUBLE
Map<String, Object> doubleField = (Map<String, Object>) properties.get("doubleField");
assertEquals(doubleField.get("type"), "double");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,10 @@ record TestEntityInfo includes CustomProperties {
}
}
esObjectField: optional map[string, string]

@Searchable = {
"fieldName": "doubleField",
"fieldType": "DOUBLE"
}
doubleField: optional double
}

0 comments on commit 7fb6086

Please sign in to comment.