Explore auto-selects an arbitrary tab when NLQ/hybrid search is enabled
TL;DR
When AI/NLQ search is enabled, Explore frequently opens the wrong tab — one holding a handful of unrelated results — while the tab that actually matches your search sits behind a click, unselected.
Search revenue by region today and Explore lands on API Endpoints (4 results) even though Tables has 24. Search user activity and it lands on API Collections, which has exactly 1 result, ahead of Tables with 5.
The cause is that the tab is picked from the single top-scoring document of a search that spans 24 indices — and under the hybrid RRF pipeline that document is chosen arbitrarily, because two dozen documents are tied at exactly the same score. The fix does not need any change to search relevance, mappings or configuration: the correct information (per-entity-type result counts) is already in the same response and is already being used for the tab badges.
Affected module: UI
Describe the bug
fetchEntityData (openmetadata-ui/src/main/resources/ui/src/utils/ExploreUtils.tsx) runs two searches when there is no explicit tab in the URL:
- a count query, hardcoded to
SearchIndex.DATA_ASSET— an alias spanning 24 indices — which supplies the per-tab hit counts; - a results query against whichever tab was selected.
The tab is derived at :254:
const topHitEntityType = res.hits.hits[0]?._source?.entityType;
and findActiveSearchIndex (ExplorePureUtils.ts:114) prefers that index over the counts whenever it has any hits at all.
That is sound for plain BM25, where hits[0] is a globally-ranked document. It is not sound for the hybrid path. OpenSearch's RRF score-ranker-processor is a phase_results_processors entry, so it ranks per shard. Every member of the dataAsset alias is pri=1, so each index contributes its own rank-1 document, and all of them land on the identical fused score. hits[0] is then whichever of those tied documents the merge happens to emit first — it carries no relevance information at all.
Measured against the running server, size=3, index=dataAsset:
q='revenue by region' #1 apiEndpoint 0.012903226 <-- tied with #2
q='shipping address' #1 apiEndpoint 0.012903226 <-- tied with #2
q='user activity' #1 apiCollection 0.012903226 <-- tied with #2
q='orders' #1 dashboardDataModel 0.032258064 <-- tied with #2
0.012903226 is 0.4/(30+1) exactly — the contribution of a document that is rank 1 in a single leg, on a single shard.
The same query restricted to one index ranks perfectly well, which confirms the ranking itself is fine and only the multi-index hits[0] is being misread:
index=table_search_index index=dataAsset (24 shards)
1 0.032258064 performance_test_table 1 0.032258064 table performance_test_table
2 0.012500000 work 2 0.012903226 apiEndpoint createTable
3 0.012121213 itm_utilization_... 3 0.012903226 dashboardDataModel ...
Impact
The arbitrary winner becomes the auto-selected tab, so the user is shown a tab that the counts in the very same response contradict:
q='revenue by region' tab chosen: apiEndpoint
counts: table=24 tag=5 worksheet=5 apiEndpoint=4 chart=2 (41 total)
q='user activity' tab chosen: apiCollection
counts: table=5 tag=4 apiEndpoint=3 apiCollection=1 (15 total)
This only affects the NLQ/hybrid path. Non-NLQ search is unaffected and its top-hit preference remains correct.
Worth noting: the count payload already sets fetchSource: false (ExploreUtils.tsx:226) precisely so _source would not be read here. It has no effect, because nlqSearch (rest/searchAPI.ts:252) destructures only seven parameters and never forwards it. So the intent to not do this is already in the code.
To Reproduce
- Enable NLQ / AI search.
- Go to Explore with no tab in the URL and search
revenue by region. - Observe the API Endpoints tab is auto-selected with 4 results, while Tables shows 24.
Directly against the API:
curl -s -H "Authorization: Bearer $JWT_TOKEN" \
"http://localhost:8585/api/v1/hybrid/nlq/search?q=revenue%20by%20region&index=dataAsset&size=3"
hits[0]._source.entityType is apiEndpoint, and hits[0]._score == hits[1]._score, while the entityType aggregation reports table=24 against apiEndpoint=4.
Expected behavior
With NLQ enabled, the auto-selected tab should be derived from the aggregation counts already present in the count response, not from hits[0] of a multi-index hybrid query. Non-NLQ behaviour should be unchanged.