I want to do paging in a query with "rescore", but I don't understand the behavior of the "from" parameter.
I would like to process the following in this order.
- Keyword search
- Sort the top 100 results using embedding
- Sort the top 30 results using the user's profile
query example:
{
query: {
bool: {
should: [
{
match: {
body1: {
query: (input keyword)
}
}
},
{
match: {
body2: {
query: (input keyword)
}
}
}
],
filter: filters,
minimum_should_match: 1
}
},
rescore: [
{
window_size: 100,
query: {
rescore_query: {
function_score: {
query: {
match_all: {}
},
functions: [
{
script_score: {
script: {
source: 'Math.max(cosineSimilarity(params.queryVector, "additional_details_vector"), 0.01)',
params: {
queryVector: (input embedding)
}
}
}
}
]
}
},
score_mode: "multiply"
}
},
{
window_size: 30,
query: {
score_mode: "multiply",
rescore_query: {
function_score: {
functions: [
{
linear: {
user_age_rank: {
origin: (input user_age_rank),
scale: 2,
offset: 0,
decay: 0.5
}
},
weight: 3
},
...
],
score_mode: "sum"
}
}
}
}
],
size: 10,
from: (input page - 1) * 10,
}
When I run the above query, for some reason, profile scoring stops on the 9th page (not the 4th page).
It seems that the embedding score is also added after page 20.
Why does this happen?
Is there any documentation about the behavior of the “from” parameter in rescore queries?