lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Miller <markrmil...@gmail.com>
Subject Re: custom similarity based on tf but greater than 1.0
Date Fri, 19 Jan 2007 00:59:44 GMT
Dont return 1 for tf...just return the tf straight with no 
changes...return freq. For everything else return 1. After that 
OMIT_NORMS should work. If you want to try a custom reader:

public class FakeNormsIndexReader extends FilterIndexReader {
    byte[] ones = SegmentReader.createFakeNorms(maxDoc());

    public FakeNormsIndexReader(IndexReader in) {
        super(in);
    }
    public synchronized byte[] norms(String field) throws IOException {
          System.out.println("returning fake norms...");
        return ones;
    }

    public synchronized void norms(String field, byte[] result, int 
offset) {
          System.out.println("writing fake norms...");
        System.arraycopy(ones, 0, result, offset, maxDoc());
    }
}

The beauty of this reader is that you can flip between it and your 
custom similarity and Lucene's default implementations live on the same 
index.

- Mark


Vagelis Kotsonis wrote:
> I feel kind of stupid...I don't get what hossman says in his post.
>
> I got the thing abou the OMMIT_NORMS and I tried to do it by calling
> Field.setOmitNorms(true); before adding a field in the index. After that I
> re-indexed my collection but still not making any difference.
>
> Tell me if I got it right. The second solution that you followed is building
> a custom FilteredIndexReader and implement these 2 functions :
>
> byte[] norms(String field)
> void norms(String field, byte[] result, int offset)
>
> Did I  get it right?
>
> Thank you and excuse me for continuously asking the same thing.
> Vagelis
>
>
> markrmiller wrote:
>   
>> Sorry your having trouble find it! Allow me...bingo: 
>> http://www.gossamer-threads.com/lists/lucene/java-user/43251?search_string=sorting%20by%20per%20doc%20hit;#43251
>>
>> Prob doesn't have great keyword for finding it. That should get you 
>> going though. Let me know if you have any questions.
>>
>> - Mark
>>
>>
>>     
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message