Skip to content

feat: OpenSearchDocumentStore emulating offset with cursor - #3692

Merged
davidsbatista merged 6 commits into
mainfrom
feat/opensearch-offset-pagination
Aug 10, 2026
Merged

feat: OpenSearchDocumentStore emulating offset with cursor#3692
davidsbatista merged 6 commits into
mainfrom
feat/opensearch-offset-pagination

Conversation

@davidsbatista

@davidsbatista davidsbatista commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

  • emulate offset with cursor with _skip_unique_values() skipping each cursor until offset is reached

How did you test it?

  • updated unit and integrations tests

Checklist

@github-actions github-actions Bot added integration:opensearch type:documentation Improvements or additions to documentation labels Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Coverage report (opensearch)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/opensearch/src/haystack_integrations/document_stores/opensearch
  document_store.py 2050, 2093, 2120-2134, 2142-2156, 2222-2232
Project Total  

This report was generated by python-coverage-comment-action

@davidsbatista
davidsbatista requested a review from sjrl July 29, 2026 16:05
@davidsbatista
davidsbatista marked this pull request as ready for review July 29, 2026 16:05
@davidsbatista
davidsbatista requested a review from a team as a code owner July 29, 2026 16:05
Comment on lines +2172 to +2174
**Note**: To keep this signature uniform across document stores, offset-based pagination is
emulated on top of the cursor by re-fetching and discarding every bucket before `from_` on each
call, requiring additional search round-trips proportional to `from_`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets also add a note along the lines of "Performance may degrade for high-cardinality metadata fields and large from_ values." to make it clear that we don't expect this method to work well on metadata values that have lots of unique values.

metadata_field: str,
search_term: str | None = None,
from_: int = 0,
size: int = 10,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you plan on adding the filters param in a future PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes coming up next.

@sjrl sjrl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Just two minor comments.

@davidsbatista
davidsbatista merged commit c3aff92 into main Aug 10, 2026
9 of 10 checks passed
@davidsbatista
davidsbatista deleted the feat/opensearch-offset-pagination branch August 10, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:opensearch type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants