Instead of allocating such arrays, we could introduce an incremental allocation behind the hood.
E.g.: we'd execute the query once to retrieve the top 100, and if there is more, we'd do it again with 200, then 400, then 800, and so on.
See org.hibernate.search.query.engine.impl.QueryHits#scoreDoc in Hibernate Search 5.
I'm not entirely sure this is how it works for queries without a limit, but I think it is. Let's check?
By the way we'd have to check this is still relevant in Search 6, too. Since we split the collection in two phases (one phase to collect topDocs + aggregations, the second to retrieve projections from top docs), this will only be a problem if the topDocs or aggregation collectors size their internal structures according to the limit. If they don't, and use automatically increasing container (List, ...), we're fine.