Michael, thank you.

Query filter only solves half of my problem. Unfortunately I do need to have a proper score for some fields.

I ended up extending Term class (I removed sealed attribute which is a bad thing). The new myTerm class has one boolean member, omitIdf. Then, when I compile my queries, I use myTerm with omitIdf set to true, for some fields. Then I extended Similarity cladd and I cast Term passes into Idf method to myTerm and only calculate Idf if omitIdf is true. Seems to work.

I don't like the solution but that's the best I could do today.

Any thoughts?

Regards,
Artem


On 10/12/2009, at 15:51, Michael Garski <mgar...@myspace-inc.com> wrote:

Artem,

Do you need any scoring information at all on that field? How about using a QueryFilter for those fields?

Michael


-----Original Message-----
From: Artem Chereisky [mailto:a.cherei...@gmail.com]
Sent: Wed 12/9/2009 4:53 PM
To: lucene-net-user@incubator.apache.org; 
lucene-net-develo...@incubator.apache.org
Subject: idf on per-field basis

Hi,

I came across a situation when my scores are adversely affected by the IDF
component. Let me explain.

My index documents contain a number of fields, for some, TF and IDF are important and need to be taken into account, for others niether TF nor IDF should apply. I dealt with TF by omiting norms during indexing but I can't
find a way to calculate IDF for certain fields only.

The formula for IDF is defined in Similarity. I have my own implementation of Similarity where I can set it to 1 or use the default implementation. mySearcher.SetSimilarity is where I tell Lucene which similarity instance to
use, but that's global, so it applies to all fields in the index.

So, here's my question. Is there a way to calculate IDF on per-field basis?

Regards,
Art


Reply via email to