-
Notifications
You must be signed in to change notification settings - Fork 6
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
search_after
param (used to paginate hits e.g. in Discover
), 1/2 strategies
#1104
base: main
Are you sure you want to change the base?
Conversation
search_after
param (used to paginate hits e.g. in Discover
)search_after
param #1 (used to paginate hits e.g. in Discover
)
ab682a7
to
e0ef92f
Compare
search_after
param #1 (used to paginate hits e.g. in Discover
)search_after
param (used to paginate hits e.g. in Discover
), part 1
Deploying quesma with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
- Having more generic timestamp method accomodating for different types would be awesome.
- Not sure what if we don't have timestamp.
- Tests.
quesma/model/search_after.go
Outdated
if searchAfter.timestampMs == emptySearchAfterTs { | ||
return query | ||
} | ||
timestampRangeClause := NewInfixExpr(s.timestampField, "<=", NewFunction("fromUnixTimestamp64Milli", NewLiteral(searchAfter.timestampMs))) // TODO fix this for Hydrolix... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not always correct, as we might have timestamps in seconds, not milliseconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always correct, because we read up the value from this:
func FormatSortValue(i any) any {
switch v := i.(type) {
case time.Time:
// When returned as part of `sort`, timestamps are always returned as millis
return v.UnixMilli()
default:
return i
}
}
As you see, if it's present, it'll always be milliseconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I definitely agree that the way it works and why it does, is way too cryptic.
quesma/model/search_after.go
Outdated
if searchAfterTs == emptySearchAfterTs { | ||
return query | ||
} | ||
timestampRangeClause := NewInfixExpr(s.timestampField, "<", NewFunction("fromUnixTimestamp64Milli", NewLiteral(searchAfterTs))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
8537659
to
100a10d
Compare
Tested that, and So unfortunately there's some TODO to do. |
fe21d60
to
c9ae36c
Compare
c9ae36c
to
216ba2d
Compare
e010e6d
to
44c3016
Compare
44c3016
to
37c46bd
Compare
search_after
param (used to paginate hits e.g. in Discover
), part 1search_after
param (used to paginate hits e.g. in Discover
), 1/2 strategies
Agreed, but let me do that in a quick next PR, this one already is quite big, wouldn't like to mess in a couple more places. |
#1099 1/2 PR
After this PR instead of discarding
search_after
param, we simply addtuple(sort_field_1, sort_field_2, ...)<(search_after_1, search_after_2, ...)
to theWHERE
clause, so we'll (almost) properly return paginated hits (never wrong ones, but we can skip some valid ones)If
sort_field_i
isasc
, we swapsort_field_i
withsearch_after_i
in the expression above, I think it gives exactly what we want.Timestamp fields use
fromUnixTimestampMilli64
conversion - it'll work because thesearch_after
param is what we returned in the previous request ourselves, for previous hits. And for dates/timestamps we always returnunix_timestamp in ms
.This strategy is not fully correct, because we'll skip all hits with exactly the same sort values (
timestamps in ms
, usually), but it's some progress anyway. Before this PR, queries with this param basically didn't work at all, now they have a small bug.TODO (I'll finish in next PR):
from...Milli64
. It'll always work for Clickhouse, but for Hydrolix andDateTime
field (without64
), it won't. It's a known issue, quick to fix. I'd do it in another PR, as before this one,search_after
didn't work anyway, so there's no regression here.Screens of this working after all the commits: