我使用3 appIndexer在kademi上使用SearchManager API搜索内容: 1.配置文件appsIndexer 2. content appsIndexer 3. blog 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上看到,我的搜索结果仍然包含学习内容。请看下面的截图:
搜索结果包含学习内容
如何使用kademi搜索管理器API从搜索结果中排除学习模块、课程等和测试页面?
发布于 2015-10-18 10:46:17
您应该使用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"]}
}
}
}
}
};https://stackoverflow.com/questions/33196770
复制相似问题