Skip to content
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

added sort_index parameter to DataFrame.to_pandas function #392

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# CHANGELOG
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased 1.x]

### Added

### Changed

### Fixed

- Fixed DataFrame.to_pandas duplication bug by adding query_compiler object method by @Arnav-Gr0ver in ([#392](https://github.com/opensearch-project/opensearch-py-ml/pull/392))

## [1.2.0]

### Added
Expand Down
7 changes: 5 additions & 2 deletions opensearch_py_ml/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,10 @@ def to_pandas(
) -> pd.DataFrame:
df_list: List[pd.DataFrame] = []
i = 0
for df in self.search_yield_pandas_dataframes(query_compiler=query_compiler):
for df in self.search_yield_pandas_dataframes(
query_compiler=query_compiler,
sort_index=query_compiler.index.os_index_field,
):
if show_progress:
i = i + df.shape[0]
if i % DEFAULT_PROGRESS_REPORTING_NUM_ROWS == 0:
Expand Down Expand Up @@ -1534,7 +1537,7 @@ def _search_yield_hits(
# Pagination with 'search_after' must have a 'sort' setting.
# Using '_doc:asc' is the most efficient as reads documents
# in the order that they're written on disk in Lucene.
body.setdefault("sort", [{sort_index: "asc"}])
body.setdefault("sort", [{sort_index: sort_index}])

# Improves performance by not tracking # of hits. We only
# care about the hit itself for these queries.
Expand Down
Loading