views:

219

answers:

1

Hi All, im doing an aplication with Lucene (im a noob with it) and im facing some problems. My aplication uses the Lucene 2.4.0 library with a custom similaraty implementation (the jar is imported)

In my app im calculating doqFreq and numDocs manually (im adding the values of all indexes and then i calculate a global value in order to use it on every query) and i want to use that values on a custom similarity implementation in order to calculate a new IDF.

The problem is that I dont know how to use (or send) the new doqFreq and numDocs values from my app on that new similarty implementation as I dont want to change lucene´s code apart from this extra class.

Any suggestions or examples? I read the docs but i dont now how to aproach this :s

Thanks

+1  A: 

You can try extending IndexReader and overriding IndexReader.docFreq() and IndexReader.numDocs(). In this subtype you can supply that you are calculating manually. I'm not sure if there are other Lucene components that are dependent on those values, so you might want to tread carefully here.

bajafresh4life
This looks like a good idea. However, be advised that Lucene calculates most of this stuff at indexing time, so if you only modify the similarity calculations only during retrieval you may not get the effect you are looking for.
Yuval F
Well i solved this problem by changing some parameters on my custom similarity implementation (a couple of functions), no problems yet. And as Yuval F says with that aproach i wont get the results that i want.Thank you
David zsl