I am using 3 appIndexer to search content on kademi using SearchManager API: 1. profile appsIndexer 2. content appsIndexer 3. blog appsIndexer
This is my js code:
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");
If you see on my custom search page http://oceanyouthplatform.olhub.com/profileSearch?q=oy+hood, my search result still contain learning content. see my screenshot below:
search result contain learning content
How to exclude learning modules, courses etc and test pages from search result using kademi search manager API?
You should use the itemType property to either specify which items to include, or specify which ones to exclude.
The simplest would be to exclude e-learning items. This needs to exclude the modules, but also module pages, courses and programs, as they are all separate item types.
However, you might find that you want to explicitly identify which items to include. The item type can be set on any content item from its properties tab.
Not filter: https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-not-filter.html
Terms filter: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
To exclude item types of module and modulePage use this: