我使用3 appIndexer使用SearchManager API在kademi上搜索内容: 1. profile appsIndexer 2.内容appsIndexer 3.博客appsIndexer
这是我的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从搜索结果中排除学习模块,课程等和测试页面?
答案 0 :(得分:0)
您应该使用itemType属性指定要包含的项目,或指定要排除的项目。
最简单的方法是排除电子学习项目。这需要排除模块,还需要排除模块页面,课程和程序,因为它们都是单独的项目类型。
但是,您可能会发现要明确标识要包含的项目。可以在其属性选项卡中的任何内容项上设置项类型。
不过滤: https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-not-filter.html
条款过滤条件: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
要排除模块和modulePage的项类型,请使用:
var searchConfig = {
"query": {
"filtered": {
"query": {
"match": {"_all":keyword}
},
"filter": {
"not" : {
"terms" : { "itemType" : ["program", "course", "module", "modulePage"]}
}
}
}
}
};