Skip to content

Commit

Permalink
feat(search): track total hit count all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow committed Sep 22, 2023
1 parent a9fd646 commit e8c5377
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,9 @@ describe('ElasticsearchService', () => {
})

describe('#getSearchRequestBody', () => {
describe('#track_total_hits', () => {
let size = 0
let payload
describe('when size is 0', () => {
beforeEach(() => {
payload = service.getSearchRequestBody({}, size)
})
it('request body does not contain track_total_hits', () => {
expect(payload).not.toHaveProperty('track_total_hits')
})
})
describe('when size is not 0', () => {
beforeEach(() => {
size = 10
payload = service.getSearchRequestBody({}, size)
})
it('request body contains track_total_hits', () => {
expect(payload).toHaveProperty('track_total_hits')
expect(payload.track_total_hits).toBe(true)
})
})
it('request body contains track_total_hits', () => {
const payload = service.getSearchRequestBody({}, 0)
expect(payload.track_total_hits).toBe(true)
})
})
describe('#buildPayloadQuery', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ElasticsearchService {
uuids,
geometry
),
...(size > 0 ? { track_total_hits: true } : {}),
track_total_hits: true,
_source: requestFields,
}
this.processRuntimeFields(payload)
Expand Down

0 comments on commit e8c5377

Please sign in to comment.