Skip to content

Commit 229e341

Browse files
committed
feat: update GetSearchResponse to use MultiSearchResponse and simplify SearchItem type
chore: introduce setupIndexes search method that ensure indexes and add update filterable attributes
1 parent 42778c6 commit 229e341

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

api/src/search/service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SearchItem, SearchType } from "./types";
1+
import { SearchResults, SearchType } from "./types";
22

33
import { BaseSearchItem } from "@dzcode.io/models/dist/_base";
44
import { ConfigService } from "src/config/service";
@@ -26,9 +26,11 @@ export class SearchService {
2626
});
2727
}
2828

29-
public search = async (query: string): Promise<SearchItem[]> => {
29+
public search = async (query: string): Promise<SearchResults> => {
3030
this.logger.info({ message: `Searching for ${query}` });
31-
return [];
31+
return {
32+
results: [],
33+
};
3234
};
3335

3436
public upsert = async <T extends BaseSearchItem>(

api/src/search/types.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import { ContributionEntity } from "@dzcode.io/models/dist/contribution";
2+
import { ContributorEntity } from "@dzcode.io/models/dist/contributor";
13
import { GeneralResponse } from "src/app/types";
4+
import { MultiSearchResponse } from "meilisearch";
5+
import { ProjectEntity } from "@dzcode.io/models/dist/project";
26

37
export interface GetSearchResponse extends GeneralResponse {
4-
searchResults: Array<SearchItem>;
8+
searchResults: SearchResults;
59
}
610

7-
export interface SearchItem {
8-
id: string;
9-
title: string;
10-
runId: string;
11-
}
11+
export type SearchResults = MultiSearchResponse<SearchItem>;
12+
13+
type SearchItem = ProjectEntity | ContributionEntity | ContributorEntity;
1214

1315
export type SearchType = "project" | "contribution" | "contributor";

0 commit comments

Comments
 (0)