Understanding Alfresco Auto-Suggest Feature

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding Alfresco Auto-Suggest Feature

angelborroy
Alfresco Employee
5 0 1,729

Alfresco provides by default an Auto-Suggest feature that returns term suggestions. For instance, if a user types "alfrasco" in the search box, the system will suggest alternative terms that exists in the repository (like "alfresco" and "alfresco4").

alfresco-suggester-share.png

 

 

Currently this feature is only integrated out of the box in the Search Results page of the Share application, but it's not available by default in Alfresco Content Application (ACA / ADF) nor in Search REST API.

Since SOLR Suggester building requires additional resources (CPU, RAM and storage), it may be worthy to consider disabling the feature if not required.

 

Configuration

Alfresco Repository

Share Services REST API exposes the auto-suggest method, that returns term suggestions by using Repository Suggester Service. This is the method used by Share application from the Search Results Page.

Default endpoint for this service is:

http://localhost:8080/alfresco/s/slingshot/auto-suggest?t=term

Repository Suggester Service can be enabled or disabled using the following key in alfresco-global.properties

solr.suggester.enabled=true

By default this property is set to true. This configuration enables Suggester Service to invoke Alfresco Search Services (SOLR) suggest handler to get the term suggestion.

Default endpoint for SOLR Suggester handler is:

http://localhost:8080/solr/alfresco/suggest?suggest.q=term

When disabling Solr Suggester in the repository by setting "solr.suggester.enabled=false" in alfresco-global.properties or as environment variable, this invocation is skipped.

Alfresco Search Services

SOLR core default configuration (available in solrconfig.xml) exposes the handler "/suggest" to provide term suggestion.

 

<searchComponent name="suggest" class="org.alfresco.solr.component.AsyncBuildSuggestComponent">
    <lst name="suggester">
        <str name="name">shingleBasedSuggestions</str>
        <str name="enabled">${solr.suggester.enabled:true}</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
        <str name="field">suggest</str>
        <str name="suggestAnalyzerFieldType">text_shingle</str>
        <str name="buildOnCommit">true</str>
    </lst>
</searchComponent>

<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
        <str name="suggest">true</str>
        <str name="suggest.count">10</str>
        <str name="suggest.dictionary">shingleBasedSuggestions</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

 

Terms suggestion are stored in the SOLR field "suggest" when calculated by the AsyncBuildSuggestComponent. Default configuration builds the Suggest Dictionary every time a change is commited to SOLR Core.

However, to prevent building the dictionary often, there is a limit to wait 1 hour (3600 s) by default between building operations. This setting is specific from the Alfresco implementation, it doesn't exist out of the box in SOLR.

SOLR Suggester configuration is available in solrcore.properties file.

 

solr.suggester.enabled=true
solr.suggester.minSecsBetweenBuilds=3600

When disabling Solr Suggester by setting "solr.suggester.enabled=false", dictionary building is skipped.

 

Disabling the feature

For the repository part, apply following settings in alfresco-global.properties or as environment variable for Docker deployments.

solr.suggester.enabled=false

This will prevent repository to invoke Search Services "/suggest" endpoint.

For the Search Services part, apply following setting in solrcore.properties for every core (alfresco, archive)

solr.suggester.enabled=false

This wil prevent SOLR to build the suggester dictionary.

 

Suggester Dictionary Building

Building the dictionary, that could happen once every hour, consumes CPU and may create some temporary files depending on the volume of the SOLR Core.

If you are experimenting that SOLR performance is getting worse periodically, the reason could be related to this process that builds the dictionary.

In addition, you may find some files in your SOLR temp folder (with names following the pattern suggester_input_* and suggester_sort_*) that are used to calculate the terms to be added to SOLR Core. These files are not removed once the building process ends, so you need to create some cron process in order to delete those files periodically. If you are using default configuration, removing files created 3 hours before or earlier could be a good criteria.

Remember that disabling the feature in Repository side won't prevent SOLR to create these temporary files, disabling the feature in SOLR Side (solrcore.properties) is required in order to stop this background process.

 

Additional references

More information on SOLR Suggester feature is available in:

About the Author
Angel Borroy is Hyland Developer Evangelist. Over the last 15 years, he has been working as a software architect on Java, BPM, document management and electronic signatures. He has been working with Alfresco during the last years to customize several implementations in large organizations and to provide add-ons to the Community based on Record Management and Electronic Signature. He writes (sometimes) on his personal blog http://angelborroy.wordpress.com. He is (proud) member of the Order of the Bee.