Search in sources :

Example 1 with NGramDistance

use of org.apache.lucene.search.spell.NGramDistance in project lucene-solr by apache.

the class ConjunctionSolrSpellCheckerTest method test.

@Test
public void test() throws Exception {
    ConjunctionSolrSpellChecker cssc = new ConjunctionSolrSpellChecker();
    MockSolrSpellChecker levenstein1 = new MockSolrSpellChecker(new LevensteinDistance());
    MockSolrSpellChecker levenstein2 = new MockSolrSpellChecker(new LevensteinDistance());
    MockSolrSpellChecker ngram = new MockSolrSpellChecker(new NGramDistance());
    cssc.addChecker(levenstein1);
    cssc.addChecker(levenstein2);
    try {
        cssc.addChecker(ngram);
        fail("ConjunctionSolrSpellChecker should have thrown an exception about non-identical StringDistances.");
    } catch (IllegalArgumentException iae) {
    // correct behavior
    }
}
Also used : NGramDistance(org.apache.lucene.search.spell.NGramDistance) LevensteinDistance(org.apache.lucene.search.spell.LevensteinDistance) Test(org.junit.Test)

Aggregations

LevensteinDistance (org.apache.lucene.search.spell.LevensteinDistance)1 NGramDistance (org.apache.lucene.search.spell.NGramDistance)1 Test (org.junit.Test)1