lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: sorting by per doc hit count
Date Wed, 20 Dec 2006 08:39:06 GMT
: problem reamins that I would like to be able to switch between the hits
: per doc Similarity and the default Similarity on  any given search. I
: was hoping that I could index with DefaultSimilarity and store the norms
: for normal relevancy searching. Then I would need to ignore or make
: constant the norms with a custom Similarity for hits per doc searching.
: It would seem that this is not as easy as I had hoped it might be.

not quite ... but it's not super tough.  if "reader" is what you use to
construct your IndexSearcher when you wnat norms, something like this
should work when you don't want lengthNorms...

   IndexReader noNormsReader = new FilteredIndexReader(reader) {
     byte[] ones = SegmentReader.createFakeNorms(maxDoc());
     public synchronized byte[] norms(String field) throws IOException {
       return ones;
     public synchronized void norms(String field, byte[] result, int offset) {
       System.arraycopy(ones, 0, result, offset, maxDoc());

it would be nice if encodeNorm, decodeNorm, and getNormDecoder weren't
static, so you could not only use whatever encoding you want at index
time, but could also ignore it alltogether at search time in the way you
describe ... but alas, that's just not the way it works -- changing it now
in a backwards compatible way would be a bit tricky.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message