public void TestMultiWord()
        {
            FuzzyLikeThisQuery flt = new FuzzyLikeThisQuery(10, analyzer);

            flt.AddTerms("jonathin smoth", "name", 0.3f, 1);
            Query       q          = flt.Rewrite(searcher.IndexReader);
            ISet <Term> queryTerms = Support.Compatibility.SetFactory.CreateHashSet <Term>();

            q.ExtractTerms(queryTerms);
            Assert.IsTrue(queryTerms.Contains(new Term("name", "jonathan")), "Should have variant jonathan");
            Assert.IsTrue(queryTerms.Contains(new Term("name", "smith")), "Should have variant smith");
            TopDocs topDocs = searcher.Search(flt, 1);

            ScoreDoc[] sd = topDocs.ScoreDocs;
            Assert.IsTrue((sd != null) && (sd.Length > 0), "score docs must match 1 doc");
            Document doc = searcher.Doc(sd[0].Doc);

            Assert.AreEqual("2", doc.Get("id"), "Should match most similar when using 2 words");
        }
        public void TestClosestEditDistanceMatchComesFirst()
        {
            FuzzyLikeThisQuery flt = new FuzzyLikeThisQuery(10, analyzer);

            flt.AddTerms("smith", "name", 0.3f, 1);
            Query     q          = flt.Rewrite(searcher.GetIndexReader());
            Hashtable queryTerms = new Hashtable();

            q.ExtractTerms(queryTerms);
            Assert.IsTrue(queryTerms.Contains(new Term("name", "smythe")), "Should have variant smythe");
            Assert.IsTrue(queryTerms.Contains(new Term("name", "smith")), "Should have variant smith");
            Assert.IsTrue(queryTerms.Contains(new Term("name", "smyth")), "Should have variant smyth");
            TopDocs topDocs = searcher.Search(flt, 1);

            ScoreDoc[] sd = topDocs.scoreDocs;
            Assert.IsTrue((sd != null) && (sd.Length > 0), "score docs must match 1 doc");
            Document doc = searcher.Doc(sd[0].doc);

            Assert.AreEqual("2", doc.Get("id"), "Should match most similar not most rare variant");
        }