Disable "Did you mean" or "Search instead for" in Alfresco basic search

cancel
Showing results for 
Search instead for 
Did you mean: 

Disable "Did you mean" or "Search instead for" in Alfresco basic search

sjoshee
Active Member
0 0 1,607

In Alfresco 5.0.x (may be other versions of Alfresco), if a search term is not found in the Solr index, the basic search provides the result for the closest term that matches in the index. For example, if the search term is "1234567" and if nothing matches in the index then basic search presents the result from the closest match such as "1234566". If a user does not pay close attention then it might lead to the confusion. Therefore, I had a business requirement to disable that feature. This can be easily achieved by changing a value in the search.get.js. Please follow these steps to disable it.

1) In Alfresco 5.0.x, search related scripts are packaged in "alfresco-remote-api-5.0.x.jar", therefore you need to unzip this jar to get the required files.

2) Copy "alfresco-remote-api-5.0.3/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.js and search.lib.js" files into "tomcat/shared/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search" folder, If folder does not exist please create folders.

3) Make following changes in the search.get.js file indicated in red.

----------------------------------------------------------------------------

search.get.js

<import resource="classpath:/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search/search.lib.js">
function main()
{
var params =
{
siteId: args.site,
containerId: args.container,
repo: (args.repo !== null) ? (args.repo == "true") : false,
term: args.term,
tag: args.tag,
query: args.query,
rootNode: args.rootNode,
sort: args.sort,
maxResults: (args.maxResults !== null) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS,
pageSize: (args.pageSize !== null) ? parseInt(args.pageSize, 10) : DEFAULT_PAGE_SIZE,
startIndex: (args.startIndex !== null) ? parseInt(args.startIndex, 10) : 0,
facetFields: args.facetFields,
filters: args.filters,
encodedFilters: args.encodedFilters,
spell : false
};

model.data = getSearchResults(params);
}

main();

--------------------------------------------------------------------------------------------------------------

4) Refresh the webscripts.