Self implemented versioning: return only top versions

We don't use elastics version feature, because every document in a version strain has a different id. But they have the same "RootId" - field value, if they belong to the same strain. There is another Field named "Version". Is there any way to get only the documents with the highest "Version" in the same RootId. We use queryString-Queries. I hope you can help me !