Area: Product
Sub-Area: Search
Issue
Default search results don't match your organization's priorities. Need to boost certain datasets, platforms, or domains in search rankings to surface the most relevant assets first.
You Might Be Asking:
- How do I customize search rankings?
- Can I boost specific datasets in search?
- How does search relevance scoring work?
Solution
- Configure search relevance weights:
# In application.yml or docker-compose-override.yml
elasticsearch:
search:
# Adjust field weights for relevance scoring
weights:
name: 10.0
description: 2.0
tags: 5.0
glossary_terms: 8.0
owners: 3.0
domain: 4.0
# Boost factors
boosts:
# Boost certified assets
has_certification: 2.0
# Boost frequently accessed
usage_percentile: 1.5
# Boost well-documented
has_documentation: 1.3
- Use GraphQL to add custom relevance scores:
Example uses Snowflake URN. This approach can be adapted for any data platform.
from datahub.emitter.mce_builder import make_dataset_urn
from datahub.emitter.rest_emitter import DatahubRestEmitter
from datahub.metadata.schema_classes import DatasetPropertiesClass
emitter = DatahubRestEmitter("http://localhost:8080")
# Add custom properties that influence search ranking
dataset_urn = make_dataset_urn("snowflake", "my_database.schema.critical_table")
custom_properties = {
"search_priority": "high",
"business_criticality": "tier1",
"data_product_tier": "gold"
}
dataset_properties = DatasetPropertiesClass(
customProperties=custom_properties
)
emitter.emit_mcp(
entity_urn=dataset_urn,
aspect_name="datasetProperties",
aspect=dataset_properties
)
- Implement custom search service with boosting logic:
Example uses Snowflake platform filter. This approach can be adapted for any data platform.
from datahub.ingestion.graph.client import DatahubClientConfig, DataHubGraph
def search_with_custom_ranking(query, filters=None):
"""
Search with custom ranking logic
"""
graph = DataHubGraph(DatahubClientConfig(server="http://localhost:8080"))
# Base search
results = graph.execute_graphql("""
query search($input: SearchInput!) {
search(input: $input) {
searchResults {
entity {
urn
... on Dataset {
name
platform { name }
properties {
customProperties {
key
value
}
}
tags {
tags {
tag { name }
}
}
}
}
}
}
}
""", variables={
"input": {
"query": query,
"type": "DATASET",
"start": 0,
"count": 100,
"filters": filters or []
}
})
# Apply custom ranking
def calculate_custom_score(result):
entity = result['entity']
score = 0
# Boost for custom properties
custom_props = {}
if 'properties' in entity and entity['properties']:
props = entity['properties'].get('customProperties', [])
custom_props = {p['key']: p['value'] for p in props}
if custom_props.get('search_priority') == 'high':
score += 50
if custom_props.get('business_criticality') == 'tier1':
score += 40
# Boost for tags
if 'tags' in entity and entity['tags']:
score += len(entity['tags'].get('tags', [])) * 5
return score
# Re-rank results
search_results = results['data']['search']['searchResults']
ranked_results = sorted(
search_results,
key=calculate_custom_score,
reverse=True
)
return ranked_results
# Usage
results = search_with_custom_ranking(
query="customer data",
filters=[{"field": "platform", "values": ["snowflake"]}]
)
Additional Notes
Search relevance tuning requires experimentation and user feedback. Monitor search analytics to understand which queries need improvement. Custom ranking should balance discoverability with relevance. Document ranking criteria for transparency.
Related Documentation
Tags:
search, relevance, ranking, customization, elasticsearch, boosting, scoring