Deane
Deane

Reputation: 8763

Is it possible to affect a Lucene rank based on a numeric value?

I have content with various numeric values, and a higher value indicates (theoretically) more valuable content, which I want to rank higher.

For instance:

These can be indexed by Lucene as a numeric value, but how can I tell Lucene to use this value in its ranking algorithm?

Upvotes: 0

Views: 570

Answers (2)

jakub.g
jakub.g

Reputation: 41378

Depending how exactly you want to proceed, you can set boost while indexing as suggested by @L.B, or if you want to make it dynamic, i.e. at search time rather than indexing time, you can use ValueSourceQuery and CustomScoreQuery.

You can see example in the question I asked some time ago: Lucene custom scoring for numeric fields (the example was tested with Lucene 3.0).

Upvotes: 1

L.B
L.B

Reputation: 116168

you can set this value using "Field.SetBoost" while indexing.

Upvotes: 4

Related Questions