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

Adjust query to OpenSearch to return accurate count when total possible results is greater than 10,000 #2729

Closed
1 task
chouinar opened this issue Nov 5, 2024 · 1 comment · Fixed by #2730
Assignees

Comments

@chouinar
Copy link
Collaborator

chouinar commented Nov 5, 2024

Summary

By default OpenSearch only counts the hits value up to 10k, but setting the track_total_hits request param to true will make it return the actual count.

While this has a slight performance hit, we already are getting accurate facet counts which means we're already counting everything anyways, so I doubt it will matter.

Acceptance criteria

  • Fix made
@chouinar chouinar self-assigned this Nov 5, 2024
@chouinar chouinar moved this from Icebox to In Review in Simpler.Grants.gov Product Backlog Nov 5, 2024
chouinar added a commit that referenced this issue Nov 7, 2024
…ults (#2730)

## Summary
Fixes #2729

### Time to review: __3 mins__

## Changes proposed
Set `track_total_hits` to True when calling OpenSearch

## Context for reviewers
While this field says it has possible performance cost due to needing to
count all the records, we also request a count for various facet counts
anyways, so I imagine this won't matter at all.

## Additional information
https://opensearch.org/docs/latest/api-reference/search/

I loaded ~16k records into my local search index. Querying it with no
filters returns this pagination info now:
```json
 {
    "order_by": "opportunity_id",
    "page_offset": 1,
    "page_size": 25,
    "sort_direction": "ascending",
    "total_pages": 676,
    "total_records": 16884
  }
```
@widal001
Copy link
Collaborator

widal001 commented Nov 7, 2024

Beep boop: Automatically setting the point and sprint values for this issue in project HHS/13 because they were unset when the issue was closed.

babebe pushed a commit that referenced this issue Nov 7, 2024
…ults (#2730)

## Summary
Fixes #2729

### Time to review: __3 mins__

## Changes proposed
Set `track_total_hits` to True when calling OpenSearch

## Context for reviewers
While this field says it has possible performance cost due to needing to
count all the records, we also request a count for various facet counts
anyways, so I imagine this won't matter at all.

## Additional information
https://opensearch.org/docs/latest/api-reference/search/

I loaded ~16k records into my local search index. Querying it with no
filters returns this pagination info now:
```json
 {
    "order_by": "opportunity_id",
    "page_offset": 1,
    "page_size": 25,
    "sort_direction": "ascending",
    "total_pages": 676,
    "total_records": 16884
  }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants