1

I'm running some query on Lucene.net that it is returning several documents with only a difference in the unit attribute

the query is: +house:5757 street:"madeup" street:creek* unit:114* remainder:66103* remainder:"114 miami fl 66103"

and i get several documents with

house:5757 street:"madeup" street:creek unit:100 remainder:"100 miami fl 66103"
house:5757 street:"madeup" street:creek unit:101 remainder:"101 miami fl 66103"
house:5757 street:"madeup" street:creek unit:102 remainder:"102 miami fl 66103"
...
house:5757 street:"madeup" street:creek unit:114 remainder:"114 miami fl 66103"
...
...
house:5757 street:"madeup" street:creek unit:200 remainder:"200 miami fl 66103"

i am retrieving the records with a

var collector = TopScoreDocCollector.create(25, true);
searcher.Search(topQuery, collector);

the problematic part is that all these documents are coming with exactly the same score 5.09505, so the unit match is not really making any difference to the document score

when the documents are indexed, this is how i'm indexing the unit field:

doc.Add(new Field("unit", unitValue, Field.Store.YES, Field.Index.NOT_ANALYZED));

Edit some googling shows that the RewriteMethod needs to be changed, but not sure exactly because i haven't seen a complete example

lurscher
  • 25,930
  • 29
  • 122
  • 185

1 Answers1

1

You have some wildcards in your search. Hits from wildcard queries in Lucene will by default return constant scores.

Wildcard queries are MultiTermQueries.

Try setting a different value for the MultiTermQuery rewrite method on your QueryParser and see if you get different results:

QueryParser.setMultiTermRewriteMethod

Jf Beaulac
  • 5,206
  • 1
  • 25
  • 46
  • it seems there are only 3 other options: SCORING_BOOLEAN_QUERY_REWRITE and two others starting like CONSTANT_SCORE_.... I tried the first one and its still doesn't paying any attention to the unit field difference for scores – lurscher Dec 15 '11 at 21:44
  • @L.B, thanks, but is not clear on that example how to create the indexReader object – lurscher Dec 16 '11 at 15:16
  • in any case, i tried and the score of all entries are still the same, the score is now just lower: 1.334... – lurscher Dec 16 '11 at 15:51
  • i tried doing `query.Rewrite( IndexReader.Open( directory ) )` but the scores of the top rows stay the same – lurscher Dec 16 '11 at 16:44