Recommender and Social Media Collections

I have created 3 social media collections:

Youtube: https://search.marjon.ac.uk/s/search.html?collection=Test_youtube&query=!nullpadre

Facebook: https://search.marjon.ac.uk/s/search.html?collection=Test_Facebook&query=!nullpadre

Twitter: https://search.marjon.ac.uk/s/search.html?collection=Test_Twitter&query=!nullpadre

using Gordon’s excellent documentation on https://demo.funnelback.co.uk/s/search.html?collection=showcase-examples

I would also like to create recommendations similar to https://demo.funnelback.co.uk/s/search.html?collection=showcase-recommender&query=information%20retrieval but can’t find any documentation. I’d also like to pull JSON recommendations back to our uni webpages. Is there any documentation on how to pull this back or can anyone help?

Cheers

Ian St John

Hi Ian -

I’d refer you to:

You’ll need to enable recommendations on each collection and perform a full update on the, then the endpoints will be available at:

https://search.marjon.ac.uk/s/recommender/similarItems.json?seedItem=URL&collection=COLLECTION

Thanks Gordon - I’ve already done all of that e.g. https://search.marjon.ac.uk/s/recommender/similarItems.json?seedItem=https://twitter.com/Marjon%2520TEP/status/883583728454336512&collection=Test_Twitter&source=default

Its the presentation I am needing some help with.

Do you have any documentation on how https://demo.funnelback.co.uk/s/search.html?collection=showcase-recommender&query=hadoop was built like you have on the other demos? I want to pull the JSON items back to web pages like this (ideally around search terms or courses).

Also where can you check for seed items?

Cheers

Ian

PS good luck with the masterclass today at IWMW

If you’re wanting to suggest social media content items on pages from non-social web collections, all components would need to be part of a meta collection and have recommendations enabled.

The seed item in your example would be the page you want the recommendations to be about (e.g. a course, or an event), and you’d want to set the scope parameter on your call to the recommender to be twitter, facebook, youtube or a comma-separated combination thereof.

The demonstration recommender collection at Showcase: Recommender was built using a single web collection, so it was only deriving recommendations from itself.

As for integrating this in your website - ideally, you’d have a small chunk of Javascript that:

  1. Knows the URL of the calling page
  2. Uses that URL as the seedItem
  3. Asynchronously requests a response from the recommender endpoint
  4. Styles the responses accordingly

There’s a block of Javascript in that showcase demo that could be a useful starting point:

<script>
// Display recommendations modal, passing current result's URL as seed
    var recommenderUrl = '/s/recommender/similarItems.json';
    
    jQuery('#search-recommender-preview').on('show.bs.modal', function (event) {
        var trigger  = jQuery(event.relatedTarget),
            seed     = jQuery(trigger).parent().parent().parent().clone()
            that     = jQuery(this)
            template = Handlebars.compile(jQuery('#search-recommender-item').html());

        jQuery.getJSON(recommenderUrl, {
            seedItem    : jQuery(seed).find('[data-url]').attr('data-url'),
            collection  : 'showcase-recommender',
            scope       : '',
            maxRecommendations: 3
        }).done(function(data) {
            if (!data.RecommendationResponse.recommendations.length) { noResults(); return; }
            
            for (i = 0, len = data.RecommendationResponse.recommendations.length; i < len; i++) {
                that.find('.search-recommender-list').append(template({
                    url: (data.RecommendationResponse.recommendations[i].itemID || ''),
                    title: (data.RecommendationResponse.recommendations[i].metaData['T'] || ''),
                    author: (data.RecommendationResponse.recommendations[i].metaData['a'] || '').replace(/\|/g, ', '),
                    desc: (data.RecommendationResponse.recommendations[i].metaData['c'] || ''),
                    img: (data.RecommendationResponse.recommendations[i].metaData['I'] || ''),
                    pages: (data.RecommendationResponse.recommendations[i].metaData['p'] || ''),
                    format: (data.RecommendationResponse.recommendations[i].metaData['f'] || ''),
                    lang: (data.RecommendationResponse.recommendations[i].metaData['l'] || '').replace(/\|/g, ', '),
                    isbn: (data.RecommendationResponse.recommendations[i].metaData['n'] || '')
                }));
            }
        })
        .fail(function() {
            noResults();
        }).always(function() {
            that.find('.modal-loader').fadeOut();
        });

        jQuery(this).find('.search-recommender-seed').html(jQuery(seed)).find('.search-tags').remove();
        jQuery(this).find('.search-recommender-seed-title').text(jQuery(trigger).text());
        jQuery(this).find('.search-recommender-seed-author').text(jQuery(seed).find('[data-author]').text());
        
        function noResults() {
            that.find('.search-recommender-list').html('<div class="alert alert-info">No recommendations found</div>');
        }
    }).on('hidden.bs.modal', function(event) {
        jQuery(this).find('.search-recommender-seed').empty();
        jQuery(this).find('.search-recommender-seed-title').empty();
        jQuery(this).find('.search-recommender-seed-author').empty();
        jQuery(this).find('.search-recommender-list').empty();
        jQuery(this).find('.modal-loader').fadeIn();
    });
});
</script>

Ok thanks Gordon - I’ll give that a go.

Ian