Dexter Lee 55f0412a33
feat(search): Add SearchScore annotation to use fields for search ranking (#4596)
* Add SearchScore annotation

* Add back test-model

* Remove search features

* Fix to John's comments

* simplify ranker

* Fix checkstyle
2022-04-07 11:07:27 -07:00

56 lines
1.4 KiB
Java

package com.linkedin.metadata.models;
import com.linkedin.data.schema.RecordDataSchema;
import com.linkedin.data.schema.TyperefDataSchema;
import com.linkedin.metadata.models.annotation.EntityAnnotation;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* A specification of a DataHub Entity
*/
public interface EntitySpec {
String getName();
EntityAnnotation getEntityAnnotation();
String getKeyAspectName();
AspectSpec getKeyAspectSpec();
List<AspectSpec> getAspectSpecs();
Map<String, AspectSpec> getAspectSpecMap();
Boolean hasAspect(String name);
AspectSpec getAspectSpec(String name);
RecordDataSchema getSnapshotSchema();
TyperefDataSchema getAspectTyperefSchema();
default List<SearchableFieldSpec> getSearchableFieldSpecs() {
return getAspectSpecs().stream()
.map(AspectSpec::getSearchableFieldSpecs)
.flatMap(List::stream)
.collect(Collectors.toList());
}
default List<SearchScoreFieldSpec> getSearchScoreFieldSpecs() {
return getAspectSpecs().stream()
.map(AspectSpec::getSearchScoreFieldSpecs)
.flatMap(List::stream)
.collect(Collectors.toList());
}
default List<RelationshipFieldSpec> getRelationshipFieldSpecs() {
return getAspectSpecs().stream()
.map(AspectSpec::getRelationshipFieldSpecs)
.flatMap(List::stream)
.collect(Collectors.toList());
}
}