Reputation: 261
Normally when using Lucene you set a search query and Lucene gives you some results where you can receive the score for each document.
In my case I want to change this procedure: I have a tuple of my database and want to pass it to Lucene to receive the score for that certain tuple in a Lucene index. Is this possible? And does anyone know how? ;)
Edit: Of course I want the score of my tuple in relation to a certain search query...
Upvotes: 1
Views: 308
Reputation: 200256
I suppose your tuple maps to a document in Lucene index. A document by itself has no score associated with it; it only gets scored relative to a specific query. How exactly do you want to encode your tuple's score? As document boost, or maybe a superposition of field boosts (I assume that you map your tuple members to document fields) + document boost?
So, you have a tuple and a query Q (possibly a complex one) and you need the score of the document from the index that corresponds to that tuple. First fetch the doc id of that document using a simple query (BooleanQuery of TermQueries); then invoke IndexSearcher.explain(Query,int) -- this will give you its score without actually executing Q.
Upvotes: 2