-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
7-1 [BE] [메인 - 검색창 - 자동완성] Elasticsearch db 연결 #55
Conversation
…nto feature/autoCompleted
…nto feature/ranking-system
…nto feature/search-result
… 현재는 사용자의 의해 쿼리조작 가능
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꽤나 대형 커밋이 되었네요 ㅎㅎ
ranking 테스트 부분과, elastic search 부분은 PR을 나눠도 좋겠습니다.
backend/src/search/search.module.ts
Outdated
HttpModule, | ||
ElasticsearchModule.registerAsync({ | ||
useFactory: () => ({ | ||
node: `http://localhost:9200`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 env 로 대체되어야하겠네요.
아마 개발서버로 배포될 때 연결이 안될텐데, password 설정까지 고려하는게 좋을 것 같습니다.
backend/src/search/search.module.ts
Outdated
}) | ||
export class SearchModule {} | ||
// -e "xpack.security.enabled=false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
password 설정한 후에는 docker 이미지에 해당 환경변수는 true로 하면 되겠습니다.
이 스택오버플로우 글을 참고하면 될 것 같습니다.
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
search controller 테스트는 /search/tests
안에 있어서, 이 파일은 지우면 좋겠습니다.
tmp.count = Number(score); | ||
result.push(tmp); | ||
}), | ||
); | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 result에 push하지 않고, Promise.all 자체를 return 해줘도 될 것 같은데요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 추후에 수정해보록하겠습니다. 이 PR은 elastic search에 관심을 두어야 할 것 같습니다.
password: process.env.REDIS_PASSWORD, | ||
}, | ||
}), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redis module에 대한 mockup을 만들어서 진행해도 좋을 것 같아요~
papers.forEach((paper) => { | ||
this.putElasticSearch(paper); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
papers 배열을 elasticSearch에 한번에 넣어도 될 것 같습니다.
initial index를 생성할 수 있다면, 더 좋은 방법이 될 것이다.
개요
기존은 자동완성기능 api를 호출할때 crossref의 해당 keyword로 5개의 데이터를 요청하였습니다.
외부의 api에 의존하다보니 시간이 1s ~ 13로 평균적으로는 5s 로 자동완성기능이라기에는 많은 요청 시간과 변동이 심했습니다.
이제 이를 elasticsearch에 캐싱하여, 한번 호출한 연관검색어는 캐싱이 되도록 설정하였습니다. (현재는 그대로 캐싱)
캐싱을 하니 10~12ms로 매우 빠르게 성능 향상을 할 수 있었습니다.
이후에 캐싱작업을 대폭 확대하여 자동적으로 BE측에서 캐싱작업을 수행하도록 보완할 예정입니다.
작업사항