-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functions to the Script context for a new Script Score Query #30303
Comments
Would like to get feedback from @rjernst @jdconrad |
Pinging @elastic/es-core-infra |
Painless is one of the few places where we can't use |
I'm for adding a new context for this -- ScoringScript is good. For now, the best way to add these methods is to add them as static methods to the ScoringScript class and whitelist them. I will work towards adding a way to have methods be called without the static type qualifier, but that will take me a bit of a time. |
We removed these from scripting in 6.0, as they are for advanced users. I don't think we should add them back. Anyone wanting to do this should write a custom script engine (and thus have access to all of the Lucene API). |
@nik9000 Can you please elaborate more on why we can't use Randomness in painless? |
@mayya-sharipova |
Closed with #34533 |
We are designing a new Script Score Query (SSQ) to replace Function Score Query (FSQ). The goal of SSQ is to have the same (and possibly more) functionalities as FSQ available only through painless script. For this, we would like to add the below functions to painless. They can be available either in the
SearchScript
or a specifically designed for scoringScoringScript
.Random score
Similar to
random_score
in FSQ:Currently painless allows to generate random values in the way below, but it is bulky, and not the exact reproduction of
random score
in FSQ:Math functions
We would like to introduce a shorter version of the following functions useful for score calculations:
Math.log10(doc['f'].value)
->log(doc['f'].value)
Math.log10(doc['f'].value + 1)
->log1p(doc['field'].value)
Math.log10(doc['f'].value + 2)
->log2p(doc['f'].value)
Math.log(doc['f'].value)
->ln(doc['f'].value)
Math.log1p(doc['f'].value + 1)
->ln1p(doc['f'].value)
Math.log(doc['f'].value + 2)
->ln2p(doc['f'].value)
Math.pow(doc['f'].value, 2)
->square(doc['f'].value)
Math.sqrt(doc['f'].value)
->sqrt(doc['f'].value)
1.0 / doc['f'].value
->reciprocal(doc['f'].value)
doc['f'].value / (k + doc['f'].value)
->rational(doc['f'].value, k)
Math.pow(doc['f'].value,a) / (Math.pow(k,a) + Math.pow(doc['f'].value,a))
->sigmoid(doc['f'].value, k, a)
Decay functions
Similar to decay functions in FSQ:
Proposed API:
Investigate how to parse date and geo parameters only one per query, and don't do the parsing for every document (store in context?).
Normalization functions ???
_max_score
in the rescore context?Other functions ???
_index[‘text’][‘word’].tf()
The text was updated successfully, but these errors were encountered: