Question

I have a problem using synonyms (Lucene 4.6.1) . These are my conf and test cases.

SynonymFilterFactory configuration.

Map<String,String> initialParams = Maps.newHashMap();
initialParams.put("synonyms","synonym.txt");
initialParams.put("ignoreCase","true");
initialParams.put("expand","true");
initialParams.put("format","solr");
initialParams.put("luceneMatchVersion",Version.LUCENE_40.toString());

SynonymFilterFactory synonymFilterFactory = new SynonymFilterFactory(initialParams);

Synonyms.txt

american league, al, a.l. , a/l
Cassius clay, Muhammad ali

Test Cases for Text #1

Text #1: The american League is on fire.

//Positive Cases (All working fine)

Assert.assertTrue(LuceneUtil.evaluate(t1, "al"));
Assert.assertTrue(LuceneUtil.evaluate(t1, "a.l."));
Assert.assertTrue(LuceneUtil.evaluate(t1, "a/l"))

//Negative Cases (Working fine)

Assert.assertFalse(LuceneUtil.evaluate(t1, "a.l.s"));
Assert.assertFalse(LuceneUtil.evaluate(t1, "a/l/s"));

//Not Working

Assert.assertFalse(LuceneUtil.evaluate(t1, "\"al capone\""));

Although I'm trying to create a phrase query "al capone", seems like lucene is querying with 2 terms al OR capone.

But with the synonyms list isn't happening since "Cassius Clay" is not matching "Cassius other words".

Test Cases for Text #2 //Working

Text #2: Muhammad ali is the best
Assert.assertFalse(LuceneUtil.evaluate(t2, "\"Cassius other words\""));

Any thoughts?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top