How do I return N results per index from multiple indexes or per type from multiple types?

Here is the use case.

I am syncing a PostgreSQL (PG) server with ElasticSearch. The PG server has
several databases and each database has many tables.

This is how it is currently setup:

PG server = multiple ES indexes
PG database = ES index
PG table = ES type
PG row = ES document

When I search the entire PG server or a single PG database, I do not want
to return the most relevant rows (documents) which is the default behavior.
Instead I want to return the most relevant tables (types) and the most
relevant five rows from each table.

How can I achieve this?

One solution I thought of is to search each type in parallel with size = 5.
Then sort by relevance in the application based on the score. Would that
work? If so, any issues with performance? Is there a better solution?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.