我使用3 appIndexer搜索使用SearchManager的API kademi內容: 1.簡介appsIndexer 2.內容appsIndexer 3.博客appsIndexer如何使用kademi search manager API從搜索結果中排除學習模塊,課程等並測試頁面?
這是我的js代碼:
keyword = params['q'];
var json = {
"query": {
"match": {"_all":keyword}
},
"highlight": {
"fields" : {
"*" : {},
"content" : {
"type" : "plain"
}
}
}
};
var sm = applications.search.searchManager;
var indexers = sm.appIndexers;
var profileIndexer = indexers.profile;
var contentIndexer = indexers.content;
var blogIndexer = indexers.blogs;
var builder = sm.prepareSearch(profileIndexer, contentIndexer, blogIndexer);
builder.setSource(JSON.stringify(json));
builder.setTypes("profile", "html");
var result = builder.execute().actionGet();
http.request.attributes.searchResults = result;
return views.templateView("/theme/debugging.html");
如果您請參閱我的自定義搜索頁面http://oceanyouthplatform.olhub.com/profileSearch?q=oy+hood,我的搜索結果仍包含學習內容。見下面我的截圖:
search result contain learning content
如何排除學習模塊,課程等,並從搜索結果頁面測試使用kademi的搜索管理API?
我下面的堆棧溢出的答案,但我仍然在我的搜索結果上獲得程序頁面。這是我的搜索網址http://oceanyouthplatform.olhub.com/oySearch?q=oy+hood 請點擊'預編程評估(html)'或'後期評估(html)'搜索結果。 –
請檢查正在返回的內容項目的itemType。我想你會發現它不在排除列表中。請注意,可以在**每個**項目上設置itemType,這會覆蓋默認值 – brad