Skip to content

feat: add keword search api#270

Merged
ninaxlee merged 9 commits intodevelopfrom
FIENMEE-430
Sep 20, 2025
Merged

feat: add keword search api#270
ninaxlee merged 9 commits intodevelopfrom
FIENMEE-430

Conversation

@ninaxlee
Copy link
Copy Markdown
Member

키워드 검색 api를 추가하였습니다.
피그마 화면상 키워드 검색 시 카테고리별로 조회가 가능한 것 같아 카테고리도 함께 조회하도록 하였습니다.
아직 정렬 기준이 정해지지 않아 추후 정렬 기준이 정해진다면 보충이 필요합니다.

@ninaxlee ninaxlee self-assigned this Aug 29, 2025
@notion-workspace
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @chsjen492, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 이벤트 검색 기능을 개선하기 위해 키워드 검색 API를 도입합니다. 사용자는 키워드와 카테고리를 사용하여 이벤트를 검색할 수 있으며, 이는 피그마 디자인 요구사항을 반영한 것입니다. 현재는 정렬 기준이 없지만, 향후 필요에 따라 보완될 예정입니다.

Highlights

  • 키워드 검색 API 추가: 이벤트에 대한 키워드 검색 기능을 제공하는 새로운 API 엔드포인트가 추가되었습니다.
  • 카테고리별 검색 지원: 피그마 디자인에 따라 키워드 검색 시 카테고리 필터링 기능이 함께 구현되었습니다.
  • 새로운 에러 클래스 정의: 검색 키워드가 비어있을 때 발생하는 KeywordIsEmptyToSearch 에러 클래스가 추가되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

키워드 검색 API를 추가하는 PR 잘 보았습니다. 전반적으로 기능 구현은 잘 되었으나, 몇 가지 개선점을 제안합니다.

주요 피드백:

  • 검색 API에서 category 파라미터가 없을 때의 처리가 필요합니다.
  • 검색어에 대한 유효성 검사를 강화하고, 잠재적인 성능 문제를 해결하기 위한 방안을 제안했습니다.

PR 제목에 'keword'를 'keyword'로 수정하면 더 명확할 것 같습니다.

자세한 내용은 각 파일의 코드 리뷰 코멘트를 참고해주세요.

Comment on lines +57 to +60
const condition = {
$or: [{ name: { $regex: new RegExp(keyword, 'i') } }, { description: { $regex: new RegExp(keyword, 'i') } }],
category: category,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

현재 검색 조건 구현에 두 가지 개선점이 보입니다.

  1. 카테고리 필터링: category 쿼리 파라미터가 제공되지 않으면 undefined 값으로 조회를 시도하게 되어 의도치 않은 결과를 낳을 수 있습니다. category가 있을 때만 필터 조건에 추가해야 합니다.
  2. 성능: namedescription 필드에 $regex를 사용하는 것은 데이터가 많아질 경우 성능 저하를 유발할 수 있습니다. MongoDB의 text index$text 연산자를 사용하면 더 효율적인 전문(full-text) 검색이 가능합니다. 스키마에 text index를 추가하는 것을 고려해보세요.

아래와 같이 수정하면 category가 있을 때만 필터링하도록 쿼리 객체를 동적으로 구성할 수 있습니다.

Suggested change
const condition = {
$or: [{ name: { $regex: new RegExp(keyword, 'i') } }, { description: { $regex: new RegExp(keyword, 'i') } }],
category: category,
}
const condition: mongoose.FilterQuery<Events> = {
$or: [{ name: { $regex: new RegExp(keyword, 'i') } }, { description: { $regex: new RegExp(keyword, 'i') } }],
}
if (category) {
condition.category = category
}

})

router.get('/search', async (req: Request, res: Response) => {
const keyword = req.query.keyword as string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

키워드의 양쪽 끝에 있는 공백을 제거하여, 공백만으로 이루어진 문자열이 검색어로 사용되는 것을 방지하는 것이 좋습니다. trim()을 사용하면 if (!keyword) 검사에서 이러한 경우를 함께 처리할 수 있습니다.

Suggested change
const keyword = req.query.keyword as string
const keyword = (req.query.keyword as string)?.trim()

@yuchem2
Copy link
Copy Markdown
Member

yuchem2 commented Aug 30, 2025

제가 설계 했던 키워드 설계 방향성과 많이 다른 것 같아요...! 한번 설계 문서 확인해주시고 작업해주시면 감사할 것 같아요:)

API 설계 내용: https://www.notion.so/beyond-imagination/BE-api-244402b8431380ae8948f1429f4c8861?p=244402b8431380ae8948f1429f4c8861&pm=s
DB 설계 내용: https://www.notion.so/beyond-imagination/BE-api-244402b8431380ae8948f1429f4c8861?p=244402b843138070a474cc2d6554b1f4&pm=s

atlas search에 필요한 인덱스는 일단 제가 fienmee-dev collections에 대해서 만들어놓은 상태입니다.

Comment thread apps/server/src/controllers/v1/events.ts Outdated
Comment thread apps/server/src/controllers/v1/events.ts Outdated
Comment thread apps/server/src/controllers/v1/events.ts Outdated
Comment thread apps/server/src/controllers/v1/events.ts Outdated
ninaxlee and others added 4 commits September 18, 2025 02:24
Co-authored-by: Jaehyun Yoon <yuchem2@gmail.com>
Co-authored-by: Jaehyun Yoon <yuchem2@gmail.com>
Co-authored-by: Jaehyun Yoon <yuchem2@gmail.com>
Co-authored-by: Jaehyun Yoon <yuchem2@gmail.com>
@ninaxlee
Copy link
Copy Markdown
Member Author

@yuchem2 제가 너무 지저분하게 짰군요.. 확인했습니다 감사합니다!

Comment on lines +91 to +92
throw new InvaildDate()
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 때문에 CI 에러 난 것 같아요~

@ninaxlee ninaxlee merged commit da8a49d into develop Sep 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants