Skip to content

Commit

Permalink
fix: index error when enable hidden match field for search
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxing9 committed Jan 13, 2025
1 parent ea7acbe commit 61f41d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,18 @@ export class AggregationService {
const recordIds = result;

if (search[2]) {
const finalSkip = skip ?? 0;
return recordIds.map((rec, index) => ({
index: finalSkip + index + 1,
fieldId: rec.fieldId,
recordId: rec.__id,
}));
const baseSkip = skip ?? 0;
const accRecord: string[] = [];
return recordIds.map((rec) => {
if (!accRecord?.includes(rec.__id)) {
accRecord.push(rec.__id);
}
return {
index: baseSkip + accRecord?.length,
fieldId: rec.fieldId,
recordId: rec.__id,
};
});
}

// step 2. find the index in current view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const SearchCountPagination = forwardRef<
).size as number;

const baseQueryRo: ISearchIndexByQueryRo = {
skip: skipLength,
skip: pageParam,
take: PaginationBuffer,
viewId: view?.id,
orderBy: viewOrderBy,
Expand Down Expand Up @@ -124,6 +124,8 @@ export const SearchCountPagination = forwardRef<
refetchOnMount: 'always',
refetchOnWindowFocus: false,
enabled: !!value,
initialData: undefined,
keepPreviousData: false,
getNextPageParam: (lastPage) => {
return lastPage.nextCursor;
},
Expand All @@ -137,7 +139,7 @@ export const SearchCountPagination = forwardRef<
finalResult[indexNumber] = result;
});
return finalResult;
}, [data]);
}, [data?.pages]);

const switchIndex = (direction: PageDirection) => {
const newIndex = currentIndex + direction;
Expand Down

0 comments on commit 61f41d9

Please sign in to comment.