Yes, I do not see an effect...

Here is my unit test that test it:

    public void testFairSimilarity() throws CorruptIndexException,
IOException, ParseException
    {
        Directory theDirectory = new RAMDirectory();
        Analyzer theAnalyzer = new FrenchAnalyzer();
        
        IndexWriter theIndexWriter = new IndexWriter(theDirectory,
theAnalyzer);
        theIndexWriter.setSimilarity(new FairSimilarity());
        
        Document doc1 = new Document();
        Field name1 = new Field(" NAME", "SHORT_SUITE", Field.Store.YES,
Field.Index.UN_TOKENIZED);
        Field content1 = new Field("CONTENT", "x 2 3 4 5 6 7 8 9 10",
Field.Store.NO, Field.Index.TOKENIZED);
        doc1.add(name1);
        doc1.add(content1);        
        theIndexWriter.addDocument(doc1);
        
        Document doc2 = new Document();
        Field name2 = new Field(" NAME", "BIG_SUITE", Field.Store.YES,
Field.Index.UN_TOKENIZED);
        Field content2 = new Field("CONTENT", "x x 3 4 5 6 7 8 9 10 11 12 13
14 15 16 17 18 19 20", Field.Store.NO, Field.Index.TOKENIZED);
        doc1.add(name2);
        doc1.add(content2);        
        theIndexWriter.addDocument(doc2);
        
        Searcher searcher = new IndexSearcher(theDirectory);
        searcher.setSimilarity(new FairSimilarity());

        QueryParser queryParser = new QueryParser("CONTENT", theAnalyzer);

        Hits hits = searcher.search(queryParser.parse("x"));

        assertEquals(2, hits.length());
        assertEquals("BIG_SUITE", hits.doc(0).get("NAME"));
        assertEquals("SHORT_SUITE", hits.doc(1).get("NAME"));
    }

Is there anything wrong ?
Thanks a lot,

Fabrice


Daniel Naber-10 wrote:
> 
> On Montag, 21. Januar 2008, Fabrice Robini wrote:
> 
>> I've tried the "fair" similarity described here
>> (http://www.nabble.com/a-%22fair%22-similarity-to5806739.html#a5806739)
>> with lucene 2.2 but it does not seems to work.
> 
> What exactly doesn't work, don't you see an effect? At least the scores 
> should change if you try with an artificial small document. Maybe you can 
> strip down your code to a small self-contained example and post it.
> 
> Regards
>  Daniel
> 
> -- 
> http://www.danielnaber.de
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Is-Fair-Similarity-working-with-lucene-2.2---tp15001250p15014224.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to