Skip to content

Commit bbfa01b

Browse files
committed
fix(person): search returns wrong values in pagination #78
1 parent 11fb508 commit bbfa01b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/person/person.controller.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export class PersonController extends BaseControllerWithFindById(
3030
description: `Этот метод предназначен для полнотекстового поиска персон по текстовому запросу. Он принимает только один параметр \`query\`. Если вам нужны фильтры, гибкость и множество результатов, используйте метод \`Универсальный поиск с фильтрами\` (findMany). В этом методе также не доступен выбор полей. А в ответ приходит упрощенная модель, которая подходит только для отображения результатов поиска.`,
3131
})
3232
async searchPerson(@Query() query: SearchDto): Promise<SearchPersonResponseDto> {
33-
const data = await this.service.searchPerson(query);
34-
return data;
33+
return this.service.searchPerson(query);
3534
}
3635

3736
@Version('1.1')

src/person/person.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ export class PersonService extends BaseService<Person> {
3535

3636
return {
3737
docs: personEntities,
38-
total: searchResponse.totalHits,
38+
total: searchResponse.estimatedTotalHits,
3939
limit: dto.limit,
4040
page: dto.page,
41-
pages: Math.ceil(searchResponse.totalHits / dto.limit),
41+
pages: Math.ceil(searchResponse.estimatedTotalHits / dto.limit),
4242
};
4343
}
4444

0 commit comments

Comments
 (0)