rajat315315 commented on PR #16431:
URL: https://github.com/apache/lucene/pull/16431#issuecomment-5119357376

   > Can we have an example and a test for a "homemade" function that followins 
decreasing or increasing logic? I want this to be defined together with the 
function! 
   
   I have attached a test specifying `DoubleValuesSource` where scoring is done 
using `Math.sqrt()` which is a monotonically increasing function.
   
   >  The caller who constructs a FunctionQuery should not need to kown if the 
function heshe uses is increasing!
   
   The caller constructing a `FunctionScoreQuery` **does not need to know or 
specify whether the function is increasing or decreasing**:
   
   ```java
   // Clean, transparent caller API (no boolean flags needed):
   Query query = new FunctionScoreQuery(baseQuery, doubleValuesSource);
   ```
   
   
   > What happens if you use a ValueSource with an increasing function and you 
wrap it with another decreasing function (nesting)? 
   
   When nesting functions $f(g(x))$, monotonicity composes deterministically:
   
   | Outer Function              | Inner Function              | Composed 
Result | Outer `getMaxScore()` Delegates To         |
   | :----------------------------| :----------------------------| 
:----------------| :-------------------------------------------|
   | **Increasing** ($\sqrt{u}$) | **Increasing** ($x$)        | **Increasing** 
 | `inner.getMaxScore(upTo)`                  |
   | **Increasing** ($\sqrt{u}$) | **Decreasing** ($-x$)       | **Decreasing** 
 | `inner.getMaxScore(upTo)` (delegated down) |
   | **Decreasing** ($-u$)       | **Increasing** ($\sqrt{x}$) | **Decreasing** 
 | `inner.getMinScore(upTo)`                  |
   | **Decreasing** ($-u$)       | **Decreasing** ($-x$)       | **Increasing** 
 | `inner.getMinScore(upTo)`                  |
   
   If any layer in the nesting chain is non-monotonic or lacks skip index 
information, it returns `Float.POSITIVE_INFINITY`, making nested expressions 
safe by construction.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to