Calculate cosine similarity in Apache Spark
There's a related example to your problem in the Spark repo here.  The strategy is to represent the documents as a RowMatrix and then use its columnSimilarities() method.  That will get you a matrix of all the cosine similarities.  Extract the row which corresponds to your query document and sort.  That will give the indices of the most-similar documents.  

Depending on your application, all of this work can be done pre-query.