When I query SOSL with multiple RETURNING objects, the result comes as a list of lists, each for a different sObjectType, each sorted by default by the "relevance" of each record in the result set.

Is it possible to combine these per-object results into a single list, while keeping the cross-object relevance sort order?

The goal is to be able to search across multiple sObjectTypes and take the top N (5-10) most relevant results, regardless of the sObjectType.

1 Answer 1


SOSL doesn't provide a relevance index, so there's no way to perfectly guarantee they'll be in descending order, and it also doesn't provide a way to get a collated list across all objects. There simply isn't an API for it. You could choose the show the first one or two items from each list (the most relevant), but there's no way to know their relative ordering.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .