如何使用 kademi 搜索管理器 API 从搜索结果中排除学习模块、课程等和测试页面?
How to exclude learning modules, courses etc and test pages from search result using kademi search manager API?
我正在使用 3 appIndexer 通过 SearchManager 在 kademi 上搜索内容 API:
1.配置文件应用程序索引器
2. 内容应用索引器
3. 博客应用索引
这是我的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?
您应该使用 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
要排除模块和模块页面的项类型,请使用:
var searchConfig = {
"query": {
"filtered": {
"query": {
"match": {"_all":keyword}
},
"filter": {
"not" : {
"terms" : { "itemType" : ["program", "course", "module", "modulePage"]}
}
}
}
}
};
我正在使用 3 appIndexer 通过 SearchManager 在 kademi 上搜索内容 API: 1.配置文件应用程序索引器 2. 内容应用索引器 3. 博客应用索引
这是我的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?
您应该使用 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
要排除模块和模块页面的项类型,请使用:
var searchConfig = {
"query": {
"filtered": {
"query": {
"match": {"_all":keyword}
},
"filter": {
"not" : {
"terms" : { "itemType" : ["program", "course", "module", "modulePage"]}
}
}
}
}
};