Search across Entries and Assets and paginate combined results I need to search both entries and assets and paginate the combined result.

I have tried:

{% set entries = craft.entries.search(query|trim).order('score').status('pending, live').find() %}
{% set assets = craft.assets.source('documentLibrary').search(query).find() %}
{% set searchResults = entries | merge(assets) %}


But then I can't get paginate to work:

{% paginate searchResults as results %}


... brings up the following error:


  Argument 1 passed to Craft\TemplateHelper::paginateCriteria() must be an instance of Craft\ElementCriteriaModel, array given


If I don't use a .find(), I can't merge the two objects.

Any ideas how this can be achieved?
You're getting that error because as soon as you call find(), you're converting the ElementCriteriaModel into an array of actual fetched elements and the {% paginate %} tag requires an ElementCriteriaModel object to be passed in.

In order to pull off what you're looking for, you'd need to ability to search across multiple element types in one query, which is currently not something Craft supports.

Consider voting for this feature request, which would enable what you're trying to do.