Skip to content

MB-67212: Supporting search_after/search_before for deep pagination over non textual content - #2208

Merged
capemox merged 5 commits into
masterfrom
deep-pagination-non-textual
Jul 21, 2025
Merged

MB-67212: Supporting search_after/search_before for deep pagination over non textual content#2208
capemox merged 5 commits into
masterfrom
deep-pagination-non-textual

Conversation

@capemox

@capemox capemox commented Jul 18, 2025

Copy link
Copy Markdown
Member

Add search after functionality for numeric, datetime, and geo fields in TopNCollector

  • Introduced new test cases for searching after numeric, datetime, and geo fields.
  • Implemented encoding for pagination on these fields to enhance search capabilities.
  • Updated the createSearchAfterDocument function to support encoded sort values.
  • Ensured proper handling of search results in the new test cases.

This enhances the search functionality by allowing users to paginate through results based on specific criteria.

…in TopNCollector

- Introduced new test cases for searching after numeric, datetime, and geo fields.
- Implemented encoding for pagination on these fields to enhance search capabilities.
- Updated the createSearchAfterDocument function to support encoded sort values.
- Ensured proper handling of search results in the new test cases.

This enhances the search functionality by allowing users to paginate through results based on specific criteria.
Comment thread search/collector/topn.go Outdated
Comment thread search/collector/topn.go Outdated
Comment thread search/collector/topn.go Outdated

@CascadingRadium CascadingRadium left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above comments

capemox added 2 commits July 21, 2025 14:17
…nd geo fields

- Added a new function `validatePagination` to check the validity of `SearchAfter` and `SearchBefore` values based on the sort order.
- Introduced comprehensive test cases to validate pagination behavior for various field types.
- Updated the `SearchRequest.Validate` method to incorporate pagination validation.
- Adjusted the handling of encoded sort values in the `TopNCollector` for improved search functionality.
@capemox
capemox requested a review from CascadingRadium July 21, 2025 08:59
Comment thread search.go Outdated

@CascadingRadium CascadingRadium left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small refactor

@capemox
capemox requested a review from CascadingRadium July 21, 2025 09:49
Comment thread search.go Outdated
@capemox capemox self-assigned this Jul 21, 2025

@abhinavdangeti abhinavdangeti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@capemox would we not need to extend support for search_before as well or do both paths have overlap?

In a separate follow up PR, would you add a docs/pagination.md following similar syntax to the others in docs/ showcasing how users can use the traditional pagination and how they can use search_after/search_before for better performance during deep pagination.

Comment thread search/collector/topn.go
}

// Creates a dummy document to compare with for pagination.
func createSearchAfterDocument(sort search.SortOrder, after []string) *search.DocumentMatch {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget this, but are there no such utilities for searchBefore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally, SearchBefore is converted to a SearchAfter problem by reversing the sort order, so we don't need to handle both cases separately

bleve/index_impl.go

Lines 584 to 589 in 487fa5f

if req.SearchBefore != nil {
reverseQueryExecution = true
req.Sort.Reverse()
req.SearchAfter = req.SearchBefore
req.SearchBefore = nil
}

@abhinavdangeti abhinavdangeti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @capemox ! Feel free to merge away.

@abhinavdangeti abhinavdangeti added this to the v2.5.3 milestone Jul 21, 2025
@capemox
capemox merged commit 195a44a into master Jul 21, 2025
9 checks passed
@abhinavdangeti
abhinavdangeti deleted the deep-pagination-non-textual branch July 22, 2025 13:59
CascadingRadium pushed a commit that referenced this pull request Aug 21, 2025
…ver non textual content (#2208)

Add search after functionality for numeric, datetime, and geo fields in
TopNCollector

- Introduced new test cases for searching after numeric, datetime, and
geo fields.
- Implemented encoding for pagination on these fields to enhance search
capabilities.
- Updated the createSearchAfterDocument function to support encoded sort
values.
- Ensured proper handling of search results in the new test cases.

This enhances the search functionality by allowing users to paginate
through results based on specific criteria.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants