A fix for custom Similarity to be used in queries