Implement the search-logic for documents, based on the original play version (jpa helps)