Area: UI
Sub-Area: Search
Applies to: OSS + Cloud
Issue
You want to find assets with more than a plain keyword search. You want to combine terms, search a single field, apply several filters, or run the same search through the GraphQL API.
You Might Be Asking
- Which operators does the search bar support?
- How do I search a specific field, such as a name or a column?
- Can I combine several filters?
- How do I filter by platform or tag in GraphQL?
Cause
The search bar and the GraphQL API follow rules that differ from common search engines:
- The search bar uses AND by default. Every word must match.
- Field-specific searches need the
/qstructured query prefix. - The words
AND,ORandNOTare not operators in a normal search. - Platform and tag filters take full URNs, not bare names.
Solution
1. Use the search bar operators
In a normal search:
- The default logic is AND.
information about ordersis read asinformation AND about AND orders. - Wrap terms in double quotes for an exact match, for example
"pet profile". - Put
-before a term to exclude it, for examplelogging -snowflake. - Use parentheses to set the precedence of boolean expressions. The search guide's example is
logging + (-snowflake | os_audit_log).
The words OR and NOT are not operators in a normal search. The word OR works only inside a /q query.
If Search V3 keyword reads are on, a query matches any of its words. The characters -, +, |, parentheses, ~ and * are then treated as plain text, and a bare * still matches everything. Use /q for boolean logic in that case. Search V3 keyword reads are off by default in OSS. On Cloud, contact DataHub Support to ask whether your instance has it on.
See Search operators.
2. Search a specific field with /q
Start the query with /q to search a field. Examples from the search guide:
/q name: *mask*
/q fieldPaths: latitude
/q editedDescription: *logical* OR description: *logical*
/q browsePaths: *hive*
/q hasUpstreams:true
Leading wildcards such as *mask* appear in the guide only inside /q queries. The guide documents no ? single-character wildcard.
See Advanced queries.
3. Combine filters in the UI
The filters sidebar is on the left of the search results. You can filter by Data Platform, Tags, Glossary Terms, Domain, Owners and more.
For more control, click Advanced at the top right of the filter panel. Advanced Filters support Column Name, Container, Domain, Description, Tag, Glossary Term, Owner, Entity Type, Subtype, Environment and soft-deleted status. Description, Tag and Glossary Term can apply to the entity or to a column.
- By default all filters must match. Switch all filters to any filter to match any one of them.
- You can negate each advanced filter.
A facet in the filter list returns only its top values. In OSS the default is 20 values per facet, set by ELASTICSEARCH_QUERY_DEFAULT_MAX_AGG_VALUES. Values with lower counts can be missing from the dropdown. On Cloud, contact DataHub Support if a filter list is missing values you expect.
See Advanced filters.
4. Filter in GraphQL with orFilters
The search query searches one entity type. type and query are required. The filters argument is deprecated. Use orFilters, which is a list of { and: [...] } groups. The groups are combined with OR, and the conditions inside each group are combined with AND.
Platform and tag values must be full URNs:
query advancedSearch {
search(
input: {
type: DATASET
query: "customer"
start: 0
count: 50
orFilters: [
{
and: [
{ field: "platform", values: ["urn:li:dataPlatform:snowflake", "urn:li:dataPlatform:bigquery"] }
{ field: "tags", values: ["urn:li:tag:PII"] }
]
}
]
}
) {
searchResults {
entity {
urn
}
}
}
}
Each filter has field, values, and optional negated and condition.
searchFlags does not sort results. It controls options such as fulltext, skipCache, skipAggregates, maxAggValues and includeSoftDeleted. The search query has no sort field. To sort, use searchAcrossEntities, which accepts sortInput with sortCriteria. Each criterion has a field and a sortOrder of ASCENDING or DESCENDING.
See the GraphQL reference.
5. Run the query from Python
DataHubGraph.execute_graphql returns the data payload, so do not index ["data"] again:
def advanced_search(graph, query, platform_urns):
gql = """
query search($query: String!, $orFilters: [AndFilterInput!]) {
search(input: {
type: DATASET
query: $query
orFilters: $orFilters
start: 0
count: 100
}) {
searchResults {
entity { urn }
}
}
}
"""
variables = {
"query": query,
"orFilters": [
{"and": [{"field": "platform", "values": platform_urns}]}
],
}
result = graph.execute_graphql(gql, variables=variables)
return [r["entity"] for r in result["search"]["searchResults"]]
Pass a DataHubGraph client as graph. On Cloud, the server URL is https://<your-instance>.acryl.io/gms and you authenticate with a personal access token.
6. Search more than 10,000 results
The search UI pages through only the first 10,000 results. For larger result sets, use the scrollAcrossEntities GraphQL API instead of paging search. See Searching at scale.