Skip to content

Commit

Permalink
feat: update GetSearchResponse to use MultiSearchResponse and simplif…
Browse files Browse the repository at this point in the history
…y SearchItem type

chore: introduce setupIndexes search method that ensure indexes and add update filterable attributes
  • Loading branch information
omdxp committed Dec 21, 2024
1 parent 42778c6 commit 229e341
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 5 additions & 3 deletions api/src/search/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SearchItem, SearchType } from "./types";
import { SearchResults, SearchType } from "./types";

import { BaseSearchItem } from "@dzcode.io/models/dist/_base";
import { ConfigService } from "src/config/service";
Expand Down Expand Up @@ -26,9 +26,11 @@ export class SearchService {
});
}

public search = async (query: string): Promise<SearchItem[]> => {
public search = async (query: string): Promise<SearchResults> => {
this.logger.info({ message: `Searching for ${query}` });
return [];
return {
results: [],
};
};

public upsert = async <T extends BaseSearchItem>(
Expand Down
14 changes: 8 additions & 6 deletions api/src/search/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { ContributionEntity } from "@dzcode.io/models/dist/contribution";
import { ContributorEntity } from "@dzcode.io/models/dist/contributor";
import { GeneralResponse } from "src/app/types";
import { MultiSearchResponse } from "meilisearch";
import { ProjectEntity } from "@dzcode.io/models/dist/project";

export interface GetSearchResponse extends GeneralResponse {
searchResults: Array<SearchItem>;
searchResults: SearchResults;
}

export interface SearchItem {
id: string;
title: string;
runId: string;
}
export type SearchResults = MultiSearchResponse<SearchItem>;

type SearchItem = ProjectEntity | ContributionEntity | ContributorEntity;

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

0 comments on commit 229e341

Please sign in to comment.