cancel
Showing results for 
Search instead for 
Did you mean: 

Faceted search customization

itzamna
Confirmed Champ
Confirmed Champ
Hi,
I've created a new page which is a copy of the faceted search. I now want to accomplish the following: The search result should only consider documents (from cm:content or any particular other type from our custom content model). But no folders, datalists, forumposts, links, wikipages that may also contain the search term. Please see attachment.
What is the approach to get it working our way? How I can influence the the search itself?

This is the part of my current definition of the AlfSearchList. Not sure if that's the hook point?

// Build the searchDocLib model
// Docu: https://dev.alfresco.com/resource/docs/aikau-jsdoc/AlfSearchList_.html
var searchDocLib = {
   id: "FCTSRCH_SEARCH_RESULTS_LIST",
   name: "alfresco/search/AlfSearchList",
   config: {
      viewPreferenceProperty: "org.alfresco.share.searchList.viewRendererName",
      view: viewRendererName,
      waitForPageWidgets: true,
      useHash: true,
      useLocalStorageHashFallback: true,
      hashVarsForUpdate: [
         "searchTerm",
         "facetFilters",
         "sortField",
         "sortAscending",
         "query",
         "scope"
      ],
      selectedScope: "repo",
      useInfiniteScroll: true,
      siteId: null,
      rootNode: repoRootNode,
      repo: true,
      additionalControlsTarget: "FCTSRCH_RESULTS_MENU_BAR",
      additionalViewControlVisibilityConfig: hideOnZeroResultsConfig,
      widgets: [


Thanks for any hint on that!
1 ACCEPTED ANSWER

ddraper
World-Class Innovator
World-Class Innovator

You have a number of options here... I think that your best bet is to actually create a custom service that extends the alfresco/services/SearchService. You should override the "onSearchRequest" function and update the "payload" argument that is provided in order to add additional search queries to either the "term" or add new attributes to be processed as query attributes.

For example:

define(["dojo/_base/declare",
        "alfresco/services/SearchService"],
       function(declare,SearchService) {

  return declare([SearchService], {
   
    onSearchRequest: function(payload) {
      payload.term = payload.term + "" // <- Add more search terms

      payload.datatype = "cm:content"; // Added as a query parameter

      this.inherited(arguments); // This calls the superclass function
    }
  });
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

You can then use your custom service in place of the regular SearchService (remember to remove the original SearchService from the list of services!)

When the AlfSearchList publishes a request to search, your custom service will process the request - updating the published payload with additional data and then call the original service function to process the request as usual.

This blog post shows how to add a new package (that you'll want for your custom search service module) via an extension module.

View answer in original post

3 REPLIES 3

ddraper
World-Class Innovator
World-Class Innovator

You have a number of options here... I think that your best bet is to actually create a custom service that extends the alfresco/services/SearchService. You should override the "onSearchRequest" function and update the "payload" argument that is provided in order to add additional search queries to either the "term" or add new attributes to be processed as query attributes.

For example:

define(["dojo/_base/declare",
        "alfresco/services/SearchService"],
       function(declare,SearchService) {

  return declare([SearchService], {
   
    onSearchRequest: function(payload) {
      payload.term = payload.term + "" // <- Add more search terms

      payload.datatype = "cm:content"; // Added as a query parameter

      this.inherited(arguments); // This calls the superclass function
    }
  });
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

You can then use your custom service in place of the regular SearchService (remember to remove the original SearchService from the list of services!)

When the AlfSearchList publishes a request to search, your custom service will process the request - updating the published payload with additional data and then call the original service function to process the request as usual.

This blog post shows how to add a new package (that you'll want for your custom search service module) via an extension module.

ddraper
World-Class Innovator
World-Class Innovator

I've written up a solution in this blog post. It contains a link to a sample solution, although some further tweaking maybe required.

ddraper
World-Class Innovator
World-Class Innovator

After writing up the blog post I subsequently fixed the issue. See AlfSearchList should be configurable to publish additional query parameters · Issue #1240 · Alfresco... / [AKU-1111] AlfSearchList should be configurable to publish additional query parameters - Alfresco JI... 

So from Aikau 1.0.96 it is possible to configure the "additionalQueryParameters" attribute on the AlfSearchList widget to achieve this requirement.