• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lucene - get hit scoring

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Question regarding Lucene:

I would like to be able to get the score for each a hit returned to use for post processing. Hit.score() is deprecated, so is there a way to still do this? Much Googling has turned up nothing.

thanks,

Allasso


 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
what version of Lucene do you use?

For 2.9 try this:
returns an instance of this class. Calls to return a Hit instance.
And - returns score for this hit.

Hope it helps,
Oleg.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using 2.9.1, for which all those methods are deprecated. In fact, the Hits class is deprecated.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as a question for academic sake, however, iterator is not a static method, so if I:

Iterator iterator = Hits.iterator();

I get the infamous:

"non-static method iterator() cannot be referenced from a static context" compile-time error

Hits has no constructor, so I cannot instantiate Hits either.

I am wondering how you do this?

thanks, Allasso
 
Oleg Tikhonov
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do it by accessing TopDocs


Oleg.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may not be understanding correctly, but it appears to me that you just get a TopDocs object.

As I said, my question was for academic reasons, so to state it more generically,

How do I use a method from a class that has no constructor, and has no factory methods for instatiation, yet the method is non-static?

I can't instantiate the class, and yet I can't access it from a static context, ie, class not instatiated.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I can't instantiate the class, and yet I can't access it from a static context, ie, class not instatiated.


In those cases there are generally API methods in other classes that return such an object. Reading the javadocs, other documentation and sample code will often tell you which class/method that is.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see. Thank you sir.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In answer to the original question from the op:

ScoreDoc.score

the way I got it in my app:



I think Oleg was trying to point me there in his last reply, but I wasn't seeing it.

Thank you all much.

Allasso
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic