public void TestFuzzyLikeThisQueryEquals()
        {
            Analyzer           analyzer = new WhitespaceAnalyzer();
            FuzzyLikeThisQuery fltq1    = new FuzzyLikeThisQuery(10, analyzer);

            fltq1.AddTerms("javi", "subject", 0.5f, 2);
            FuzzyLikeThisQuery fltq2 = new FuzzyLikeThisQuery(10, analyzer);

            fltq2.AddTerms("javi", "subject", 0.5f, 2);
            Assert.AreEqual(fltq1, fltq2, "FuzzyLikeThisQuery with same attributes is not equal");
        }
        public void TestNoMatchFirstWordBug()
        {
            FuzzyLikeThisQuery flt = new FuzzyLikeThisQuery(10, analyzer);

            flt.AddTerms("fernando 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", "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 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");
        }