public void testSlopScoring() throws IOException {
Directory directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random(), directory,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
.setMergePolicy(newLogMergePolicy())
.setSimilarity(new DefaultSimilarity()));
Document doc = new Document();
doc.add(newTextField("field", "foo firstname lastname foo", Field.Store.YES));
writer.addDocument(doc);
Document doc2 = new Document();
doc2.add(newTextField("field", "foo firstname zzz lastname foo", Field.Store.YES));
writer.addDocument(doc2);
Document doc3 = new Document();
doc3.add(newTextField("field", "foo firstname zzz yyy lastname foo", Field.Store.YES));
writer.addDocument(doc3);
IndexReader reader = writer.getReader();
writer.close();
IndexSearcher searcher = newSearcher(reader);
searcher.setSimilarity(new DefaultSimilarity());
PhraseQuery query = new PhraseQuery();
query.add(new Term("field", "firstname"));
query.add(new Term("field", "lastname"));
query.setSlop(Integer.MAX_VALUE);
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;