7 votes

Similarity

Similarity

The Umbraco v7 version of Similarity found in uComponents.  This version has the ability to filter on document types. You also get a macro included so you can use it on a template or in your rich text edit fields. In essence Similarity will get a list of nodes similar to the current one that you are viewing. 

Under the hood it uses Lucene and the Similarity contribution package. 

Install the package, create a data type based on Similarity, configure that datatype by providing it with the index to search on, the document types to search on and the document type properties to search on. Finally set the maximum number of documents to return.

Add the datatype to your document type. Now when you edit the document you will see a button called Find similar, clicking on this will find for you documents similar to the current one.  You can now select all or a subset of the documents that have been found.

Next you need to create a macro to display the results. One has already been installed for you called SimilarDocuments you can update this to display your results.  The macro has 2 lots of code. One form working in data type mode in this mode you are display the documents that YOU have selected. 

var docs = Model.Content.GetPropertyValue<Similarity.ValueConverter.Similar>("similarDocuments");

The other mode is blanket mode here you will get back all items that are similar you need to pass in all the parameters  

        using (var moreLikeThis = new MoreUmbracoDocsLikeThis(Model.Content.Id, index, maxNo, properties, docTypes))

        {

            var similardocs = moreLikeThis.FindMoreLikeThis(out query);

            @Html.Hidden("query",query)

            foreach (var result in similardocs)

            {

                <p>@result.PageName</p>

            }    

        }

Both modes are illustrated in the macro.  For a full working demo please view the screen cast on Vimeo 

https://vimeo.com/86717216

PLEASE NOTE PACKAGE DOES NOT WORK WITH 7.2 UPWARDS. HOWEVER YOU CAN DOWNLOAD FORKED SOURCE FROM https://bitbucket.org/jlane/similarity BUILD THAT AND COPY OVER SIMILARITY DLLS, THAT DOES WORK.

Screenshots

Package owner

Ismail Mayat

Ismail Mayat

Ismail has 10092 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 8.18.x (untested)

You must login before you can report on package compatibility.

Previously reported to work on versions: 7.1.x, 7.0.x

Package Information

  • Package owner: Ismail Mayat
  • Contributors: Jordan Lane
  • Created: 17/02/2014
  • Current version 1.0
  • .NET version 4.0
  • License MIT
  • Downloads on Our: 584