Similarity saved = searcher.getSimilarity();
try {
// no norm field (so agnostic to indexed similarity)
searcher.setSimilarity(new DefaultSimilarity());
assertHits(new FunctionQuery(
new TFValueSource("bogus", "bogus", "text", new BytesRef("test"))),
new float[] { (float)Math.sqrt(3d), (float)Math.sqrt(1d) });
assertHits(new FunctionQuery(
new TFValueSource("bogus", "bogus", "string", new BytesRef("bar"))),
new float[] { 0f, 1f });
} finally {
searcher.setSimilarity(saved);
}
}