Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gms/search): Adding support for DOUBLE Searchable type #9369

Merged
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
}