Adding a synonym list to SOLR in Alfresco 4.0

If you missed it: Alfresco Community 4.0.a is out: 
http://wiki.alfresco.com/wiki/Alfresco_Community_4.0.a
(and my category manager is part of the new feature list ;-))

One of my favorite new features is the new Apache Solr based Search Service. I’ve done an Alfresco-Solr integration project two years ago. I was very impressed by the power of Solr & mainly by the combination of Alfresco & Solr. Thus my first deeper look into Alfresco 4.0 was about to understand the new Solr based search service & how the “whole stuff” is working.

After some hours browsing the current svn HEAD & researching Alfresco’s tracking, model & query addons to solr I tried to tweak Alfresco’s schema.xml:

Task: Add basic support of synonyms

Steps-to-do:

  1. Open alf_data/solr/workspace-SpacesStore/conf/schema.xml & add a new filter org.apache.solr.analysis.SynonymFilterFactory:
  2. Stop your
  3. Delete your Solr workspaceSpacesStore data dir: alf_data/solr/workspace
  4. Start your tomcat
  5. login to Alfresco Share a create a new txt file containing “television” and “GB”
  6. wait a few seconds (solr indexing is done async!) & execute search for “TV” –> you doc should be in the result set, because “TV” is a synonym for television (alf_data/solr/workspace-SpacesStore/conf/synonyms.txt)
  7. execute search for “gigabyte” –> you doc should be in the result set, because “gigabyte” is a synonym for “GB”

welcome to the new shiny Alfresco-SOLR world 😉

Ok…it’s quick hack because the synonyms will be used for every property/field, but it is a good starting point 🙂

6 thoughts on “Adding a synonym list to SOLR in Alfresco 4.0

  1. Thank you! Working for me in Alfresco 4.0. Do you have an idea how to make the used synonyms appear on top of the search result page in Share?

    Thinking of something like “also searched for x,y,z” under the query field to inform the user that a synonym expansion of the query was made.

  2. as far as i know this is not supported/done by solr OTB. Perhaps you nee to store the synonyms list in the alfresco repo & implement a custom service to extract synonyms there.

  3. Hi Stan, I’ve done such a “did you mean” SOLR-Alfresco integration some years ago. Leveraging existing SOLR features like spellcheck, hit highlight etc. in Alfresco (Share) is currently a little bit complex because you’ll have to tweak Alfresco’s Solr schema.xml & the SearchService & UI in Alfresco.
    best, jan

  4. Hi!

    I have installes Alfresco Community 4.0d bunlde.
    Can one give me a hint to implement hit highlighting on an example?
    Thanks

  5. Hi,
    that’s gonna be a huge task. Alfrescp Solr’s implementation (especially their own DataField) doesn’t support hit highlighting yet.
    I made some first tries a few month’s when I wrote the initial post, but there were a lot of cdips & bumps…
    Cheers, jan

Leave a Reply

Your email address will not be published. Required fields are marked *