When using Dismax or eDismax you should be able to just use the field bf (Boost Functions) parameter and fill it with the name of your numeric field.
Example
I have an index with documents that contain among other fields a numeric value named first_publication_year. When I run a matchAllQuery *:*
against my index, all documents will get a score of 1. This makes the effect of the bf parameter easier to see, as 1 is an easy divisor. The sample would go with any query though.
/select?q=*:*
Result
{
"responseHeader": {
"status": 0,
"QTime": 1
},
"response": {
"numFound": 10007277,
"start": 0,
"maxScore": 1,
"docs": [
{
"first_publication_year": 2002,
"score": 1
}
]
}
}
Now I want to boost the documents based on that field, so I add that field name as bf
parameter
/select?q=*:*&bf=first_publication_year
Result
{
"responseHeader": {
"status": 0,
"QTime": 1
},
"response": {
"numFound": 10007277,
"start": 0,
"maxScore": 1425.5273,
"docs": [
{
"first_publication_year": 2015,
"score": 1425.5273
}
]
}
}
If you think that the boost is too meagre you may adjust this with function queries. This sample multiplies the first publication year with 10.
/select?q=*:*&bf=product(first_publication_year,10)
Result
{
"responseHeader": {
"status": 0,
"QTime": 465
},
"response": {
"numFound": 10007277,
"start": 0,
"maxScore": 14248.908,
"docs": [
{
"first_publication_year": 2015,
"score": 14248.908
}
]
}
}
References
This is also documented in the Solr Reference Manual.
The bf (Boost Functions) Parameter
The bf parameter specifies functions (with optional boosts) that will be used to construct FunctionQueries which will be added to the user's main query as optional clauses that will influence the score. Any function supported natively by Solr can be used, along with a boost value. For example:
recip(rord(myfield),1,2,3)^1.5