-
글쓴이글
-
2022년 3월 7일 16:32 #28924
서정우참가자진도를 나가던 도중 이전까지는 검색기능이 잘 작동 했지만 search index를 적용하면서 검색기능이 작동이 안돼 질문 드립니다.
키워드를 검색창에 입력시 아무것도 브라우저와 콘솔 모두 아무런 에러가 나오지 않습니다.
server.js
...
app.get("/search", function (req, res) {
let searchConditions =[
{
$search: {
index: 'titleSearch',
text: {
query: req.query.value,
path: 'title' // 제목날짜 둘다 찾고 싶으면 ['제목', '날짜']
}
}
}
];
db.collection("post").aggregate(searchConditions).toArray(function (err, result) {
res.render("list", { posts: result });
});
});...
2022년 3월 8일 10:05 #28991
codingapple키 마스터index만들 때 title 필드를 기입해서 만들어보거나
index: titleSearch 부분을 빼고 찾거나 그래봅시다 아니면 한글은 구려서 정확한단어 아니면 못찾을 수 있습니다
2022년 3월 8일 13:15 #29019
서정우참가자app.get("/search", function (req, res) {
let searchConditions =[
{
$search: {
// index: 'titleSearch',
text: {
query: req.query.value, //입력된 키워드 정상 출력
path: 'title' // 제목날짜 둘다 찾고 싶으면 ['제목', '날짜']
}
}
}
];
db.collection("post").aggregate(searchConditions).toArray(function (err, result) {
res.render("search", { posts: result });
});
});인덱스 수정 전 일단 index: titleSearch 부분을 빼고 찾아보았는데 역시나 똑같아서
인덱스를 수정 해 타이틀을 넣고 다시
app.get("/search", function (req, res) {
let searchConditions =[
{
$search: {
index: 'titleSearch',
text: {
query: req.query.value, //입력된 키워드 정상 출력
path: 'title' // 제목날짜 둘다 찾고 싶으면 ['제목', '날짜']
}
}
}
];
db.collection("post").aggregate(searchConditions).toArray(function (err, result) {
res.render("search", { posts: result });
});
});이상태로 해보았으나 그래도 안돼서
index: 'titleSearch', 이부분을 다시 주석 처리하고 진행했으나 여전히 똑같습니다 ㅠㅠ
-
글쓴이글
- 답변은 로그인 후 가능합니다.