Skip to content

Commit

Permalink
add displayName using name
Browse files Browse the repository at this point in the history
  • Loading branch information
harshach committed Sep 17, 2024
1 parent 0c217ef commit 27f5b07
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ public JsonObject aggregate(String query, String index, JsonObject aggregationJs
}

private static FunctionScoreQueryBuilder boostScore(QueryStringQueryBuilder queryBuilder) {

FunctionScoreQueryBuilder.FilterFunctionBuilder tier1Boost =
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
QueryBuilders.termQuery("tier.tagFQN", "Tier.Tier1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)

Map<String, Object> commonAttributes = getCommonAttributesMap(container, Entity.CONTAINER);
doc.putAll(commonAttributes);
doc.put("displayName", container.getDisplayName());
doc.put("tags", flattenedTagList);
doc.put("tier", parseTags.getTierTag());
doc.put("service_suggest", serviceSuggest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
}
Map<String, Object> commonAttributes = getCommonAttributesMap(dashboard, Entity.DASHBOARD);
doc.putAll(commonAttributes);

doc.put("displayName", dashboard.getDisplayName());
doc.put("tags", parseTags.getTags());
doc.put("tier", parseTags.getTierTag());
doc.put("chart_suggest", chartSuggest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
ingestionPipeline.getName() != null
? ingestionPipeline.getName()
: ingestionPipeline.getDisplayName());
doc.put("displayName", ingestionPipeline.getDisplayName());
doc.put("tags", parseTags.getTags());
doc.put("tier", parseTags.getTierTag());
doc.put("service_suggest", serviceSuggest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
ParseTags parseTags = new ParseTags(Entity.getEntityTags(Entity.MLMODEL, mlModel));
Map<String, Object> commonAttributes = getCommonAttributesMap(mlModel, Entity.MLMODEL);
doc.putAll(commonAttributes);
doc.put("displayName", mlModel.getDisplayName());
doc.put("tags", parseTags.getTags());
doc.put("tier", parseTags.getTierTag());
doc.put("serviceType", mlModel.getServiceType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
Map<String, Object> commonAttributes = getCommonAttributesMap(pipeline, Entity.PIPELINE);
doc.putAll(commonAttributes);
doc.put("name", pipeline.getName() != null ? pipeline.getName() : pipeline.getDisplayName());
doc.put("displayName", pipeline.getDisplayName());
doc.put("tags", parseTags.getTags());
doc.put("tier", parseTags.getTierTag());
doc.put("task_suggest", taskSuggest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
ParseTags parseTags = new ParseTags(Entity.getEntityTags(Entity.QUERY, query));
Map<String, Object> commonAttributes = getCommonAttributesMap(query, Entity.QUERY);
doc.putAll(commonAttributes);
doc.put("displayName", query.getDisplayName());
doc.put("tags", parseTags.getTags());
doc.put("tier", parseTags.getTierTag());
return doc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.service.Entity.FIELD_DESCRIPTION;
import static org.openmetadata.service.Entity.FIELD_DISPLAY_NAME;
import static org.openmetadata.service.Entity.FIELD_NAME;
import static org.openmetadata.service.jdbi3.LineageRepository.buildRelationshipDetailsMap;
import static org.openmetadata.service.search.EntityBuilderConstant.DISPLAY_NAME_KEYWORD;
import static org.openmetadata.service.search.EntityBuilderConstant.FIELD_DISPLAY_NAME_NGRAM;
import static org.openmetadata.service.search.EntityBuilderConstant.FIELD_NAME_NGRAM;
import static org.openmetadata.service.search.EntityBuilderConstant.FULLY_QUALIFIED_NAME;
import static org.openmetadata.service.search.EntityBuilderConstant.FULLY_QUALIFIED_NAME_PARTS;
import static org.openmetadata.service.search.EntityBuilderConstant.NAME_KEYWORD;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -67,6 +65,9 @@ default List<SearchSuggest> getSuggest() {
default Map<String, Object> getCommonAttributesMap(EntityInterface entity, String entityType) {
Map<String, Object> map = new HashMap<>();
List<SearchSuggest> suggest = getSuggest();
map.put(
"displayName",
entity.getDisplayName() != null ? entity.getDisplayName() : entity.getName());
map.put("entityType", entityType);
map.put("owners", getEntitiesWithDisplayName(entity.getOwners()));
map.put("domain", getEntityWithDisplayName(entity.getDomain()));
Expand Down Expand Up @@ -163,11 +164,9 @@ static List<Map<String, Object>> getLineageData(EntityReference entity) {

static Map<String, Float> getDefaultFields() {
Map<String, Float> fields = new HashMap<>();
fields.put(FIELD_DISPLAY_NAME, 10.0f);
fields.put(DISPLAY_NAME_KEYWORD, 10.0f);
fields.put(FIELD_DISPLAY_NAME_NGRAM, 1.0f);
fields.put(FIELD_NAME, 10.0f);
fields.put(NAME_KEYWORD, 10.0f);
fields.put(FIELD_NAME_NGRAM, 1.0f);
fields.put(FIELD_DISPLAY_NAME, 10.0f);
fields.put(FIELD_DESCRIPTION, 2.0f);
fields.put(FULLY_QUALIFIED_NAME, 5.0f);
fields.put(FULLY_QUALIFIED_NAME_PARTS, 5.0f);
Expand All @@ -177,6 +176,7 @@ static Map<String, Float> getDefaultFields() {
static Map<String, Float> getAllFields() {
Map<String, Float> fields = getDefaultFields();
fields.putAll(TableIndex.getFields());
fields.putAll(StoredProcedureIndex.getFields());
fields.putAll(DashboardIndex.getFields());
fields.putAll(DashboardDataModelIndex.getFields());
fields.putAll(PipelineIndex.getFields());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
.collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
Map<String, Object> commonAttributes = getCommonAttributesMap(table, Entity.TABLE);
doc.putAll(commonAttributes);
doc.put("displayName", table.getDisplayName());
doc.put("tags", flattenedTagList);
doc.put("tier", parseTags.getTierTag());
doc.put("service_suggest", serviceSuggest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.schema.entity.teams.Team;
import org.openmetadata.service.Entity;
import org.openmetadata.service.search.models.SearchSuggest;
Expand Down Expand Up @@ -39,9 +38,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
Map<String, Object> commonAttributes = getCommonAttributesMap(team, Entity.TEAM);
doc.putAll(commonAttributes);
doc.put("isBot", false);
doc.put(
"displayName",
CommonUtil.nullOrEmpty(team.getDisplayName()) ? team.getName() : team.getDisplayName());
return doc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc)
.collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
Map<String, Object> commonAttributes = getCommonAttributesMap(topic, Entity.TOPIC);
doc.putAll(commonAttributes);
doc.put("displayName", topic.getDisplayName());
doc.put("tags", flattenedTagList);
doc.put("tier", parseTags.getTierTag());
doc.put("field_suggest", fieldSuggest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.schema.entity.teams.User;
import org.openmetadata.service.Entity;
import org.openmetadata.service.search.models.SearchSuggest;
Expand Down Expand Up @@ -38,9 +37,6 @@ public Set<String> getExcludedFields() {
public Map<String, Object> buildSearchIndexDocInternal(Map<String, Object> doc) {
Map<String, Object> commonAttributes = getCommonAttributesMap(user, Entity.USER);
doc.putAll(commonAttributes);
doc.put(
"displayName",
CommonUtil.nullOrEmpty(user.getDisplayName()) ? user.getName() : user.getDisplayName());
if (user.getIsBot() == null) {
doc.put("isBot", false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static org.openmetadata.service.Entity.DOMAIN;
import static org.openmetadata.service.Entity.FIELD_DESCRIPTION;
import static org.openmetadata.service.Entity.FIELD_DISPLAY_NAME;
import static org.openmetadata.service.Entity.FIELD_NAME;
import static org.openmetadata.service.Entity.GLOSSARY_TERM;
import static org.openmetadata.service.Entity.QUERY;
import static org.openmetadata.service.Entity.RAW_COST_ANALYSIS_REPORT_DATA;
Expand All @@ -22,7 +21,6 @@
import static org.openmetadata.service.search.EntityBuilderConstant.ES_TAG_FQN_FIELD;
import static org.openmetadata.service.search.EntityBuilderConstant.FIELD_COLUMN_NAMES;
import static org.openmetadata.service.search.EntityBuilderConstant.FIELD_DISPLAY_NAME_NGRAM;
import static org.openmetadata.service.search.EntityBuilderConstant.FIELD_NAME_NGRAM;
import static org.openmetadata.service.search.EntityBuilderConstant.MAX_AGGREGATE_SIZE;
import static org.openmetadata.service.search.EntityBuilderConstant.MAX_RESULT_HITS;
import static org.openmetadata.service.search.EntityBuilderConstant.OWNER_DISPLAY_NAME_KEYWORD;
Expand Down Expand Up @@ -981,12 +979,7 @@ private static FunctionScoreQueryBuilder boostScore(QueryStringQueryBuilder quer

private static HighlightBuilder buildHighlights(List<String> fields) {
List<String> defaultFields =
List.of(
FIELD_DISPLAY_NAME,
FIELD_NAME,
FIELD_DESCRIPTION,
FIELD_DISPLAY_NAME_NGRAM,
FIELD_NAME_NGRAM);
List.of(FIELD_DISPLAY_NAME, FIELD_DESCRIPTION, FIELD_DISPLAY_NAME_NGRAM);
defaultFields = Stream.concat(defaultFields.stream(), fields.stream()).toList();
HighlightBuilder hb = new HighlightBuilder();
for (String field : defaultFields) {
Expand Down Expand Up @@ -1306,6 +1299,7 @@ private static SearchSourceBuilder buildGenericDataAssetSearchBuilder(
private static SearchSourceBuilder buildTableSearchBuilder(String query, int from, int size) {
QueryStringQueryBuilder queryStringBuilder =
buildSearchQueryBuilder(query, TableIndex.getFields());

FunctionScoreQueryBuilder queryBuilder = boostScore(queryStringBuilder);
HighlightBuilder hb =
buildHighlights(List.of("columns.name", "columns.description", "columns.children.name"));
Expand Down

0 comments on commit 27f5b07

Please sign in to comment.